[Python-ideas] Allow __len__ to return infinity

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Feb 26 00:40:59 CET 2014


Steven D'Aprano wrote:
> (1) __len__ can return *any* float, regardless of value, including 
> lengths of 0.5, NAN, 1e300, etc. This is undesirable because lengths of 
> sequences should be positive or zero whole numbers,

What about things other than sequences?

For a vector type, for example, it would make sense
for len(v) to return the magnitude of the vector.

-- 
Greg


More information about the Python-ideas mailing list