21
Typed Python: Choose Sequence over List
(blog.meadsteve.dev)
Welcome to the Python community on the programming.dev Lemmy instance!
Past
November 2023
October 2023
July 2023
August 2023
September 2023
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
:yeah it's an interesting case that an int can be treated as a float. I should probably update my post to mention that it's not strictly a supertype but a special exception mentioned in python's typehinting pep: https://peps.python.org/pep-0484/#the-numeric-tower