2 ms·
Not sure if this is exactly what you're asking but one can reassign variables to change their types in Python: >>> x = 1 >>> type(x) <class 'int'>
by tedmiston 9y ago
Not sure if this is exactly what you're asking but one can reassign variables to change their types in Python:
>>> x = 1
>>> type(x)
<class 'int'>
>>> x = 'foo'
>>> type(x)
<class 'str'>
- xapata 9y agoI believe the question was about inferred static typing for union types. Python does not do any static type inference. Also, I'm not sure how a union type could be distinguished from an error during type inference. Maybe a nullable, but otherwise it'd be very tricky.