it:programmiersprache:python:typehints

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
it:programmiersprache:python:typehints [23.08.2025 08:36] – ↷ Seite von it:python:typehints nach it:programmiersprache:python:typehints verschoben marschit:programmiersprache:python:typehints [23.08.2026 21:33] (aktuell) marsch
Zeile 3: Zeile 3:
  
 > <wrap em hi>ab Python 3.10</wrap> [[https://peps.python.org/pep-0604/|PEP 604]] – Allow writing union types as X | Y > <wrap em hi>ab Python 3.10</wrap> [[https://peps.python.org/pep-0604/|PEP 604]] – Allow writing union types as X | Y
 +
 +
 +===== Standard Typen =====
 +
 +int
 +str
 +...
 +
 +
 +===== Benutzerdefinierte Typen =====
 +
 +Check
 +<code python>
 +from typing import NewType
 +
 +RGB = NewType("RGB", tuple[int, int, int])
 +</code>
 +
 +Check
 +<code python>
 +from typing import TypeVar
 +
 +TypeVar .....                                 # < 3.12
 +</code>
 +
 +
 +===== Generische Typen =====
 +
 +<code python>
 +def funktion[T](items: list[T]) -> T:         # ab 3.12
 +</code>
 +
  • it/programmiersprache/python/typehints.1755938172.txt.gz
  • Zuletzt geändert: 23.08.2025 08:36
  • von marsch