MeadSteve@reddthat.com to Python@programming.devEnglish · 1 year agoTyped Python: Choose Sequence over Listblog.meadsteve.devexternal-linkmessage-square3fedilinkarrow-up12arrow-down10file-text
arrow-up12arrow-down1external-linkTyped Python: Choose Sequence over Listblog.meadsteve.devMeadSteve@reddthat.com to Python@programming.devEnglish · 1 year agomessage-square3fedilinkfile-text
minus-squarechemacortes@programming.devlinkfedilinkEnglisharrow-up1·1 year agoSequence now lives at collections.abc. BTW, float is not a supertype of int (issubclass(int, float) == False). Normaly, It is acceptable to use int instead of float, but speaking of variance, it is more precise to use numbers.Real: issubclass(Integral, Real) == True issubclass(int, Real) == True issubclass(float, Real) == True issubclass(complex, Real) == False
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