Skip to content Skip to sidebar Skip to footer

How To Define An Alias For A Type In Python For Type Hinting

How to define an alias for a type to use type hint: import typing type Ticker str # How to do this? I used golang notation. How do you do it in python? Report = typing.Dict[Ticker,

Solution 1:

As you do with all other names that you bind to objects:

Ticker = typing.Text

See https://docs.python.org/3/library/typing.html#type-aliases

Post a Comment for "How To Define An Alias For A Type In Python For Type Hinting"