chemacortes@programming.devtoPython@programming.dev•Has using 'thing = list[str]()' instead of 'thing: list[str] = []' any downsides?
2·
1 year agoWith the dump
function:
from ast import dump, parse
st = parse("thing = list[str]()")
print(dump(st, indent=4))
st = parse("thing: list[str] = []")
print(dump(st, indent=4))
Sequence
now lives atcollections.abc
. BTW,float
is not a supertype ofint
(issubclass(int, float) == False
). Normaly, It is acceptable to useint
instead offloat
, but speaking of variance, it is more precise to usenumbers.Real
:issubclass(Integral, Real) == True issubclass(int, Real) == True issubclass(float, Real) == True issubclass(complex, Real) == False