Before Python 3.10, you need to use typing.Union to declare that a variable can have one of several different types.
typing.Union
In Python 3.10, you can replace Union[X, Y] with X | Y to simplify the expression.
Union[X, Y]
X | Y
Simplify Nested Structures with Python Data Classes
Simplify Object Creation with Python Class Methods
Optimizing Memory Usage in Python with Slots
Your email address will not be published. Required fields are marked *
Name
Email
Website
Save my name, email, and website in this browser for the next time I comment.
Δ