Create Union type without hard-coding in Python3 typing

Viewed 285

In python3 typing, how can I create new type using Union without hard-coding?

My attempt was, let's say I want to creat Union[int, float], as follows, which ends with SyntaxError:

from typing import Union
types = [int, float]
T = Union[*types] # want to create T = Union[int, float]
0 Answers
Related