it:programmiersprache:python:typehints

Dies ist eine alte Version des Dokuments!


Python Typehints

ab Python 3.10 PEP 604 – Allow writing union types as X | Y

Generic Types

Check

from typing import NewType
 
RGB = NewType("RGB", tuple[int, int, int])

Check

from typing import TypeVar
 
TypeVar .....                                 # < 3.12
def funktion[T](items: list[T]) -> T:         # ab 3.12
  • it/programmiersprache/python/typehints.1787519838.txt.gz
  • Zuletzt geändert: 23.08.2026 21:17
  • von marsch