4 ms·
Just to be clear, because it's buried everywhere and it's only in the original PEP page, these are examples of the new statement: # A non-generic type alias
by gnulinux 3y ago
Just to be clear, because it's buried everywhere and it's only in the original PEP page, these are examples of the new statement:
# A non-generic type alias
type IntOrStr = int | str
# A generic type alias
type ListOrSet[T] = list[T] | set[T]
# A type alias that includes a forward reference
type AnimalOrVegetable = Animal | "Vegetable"
# A generic self-referential type alias
type RecursiveList[T] = T | list[RecursiveList[T]]