len() should always return something

Piet van Oostrum piet at cs.uu.nl
Sat Jul 25 10:08:27 EDT 2009

>>>>> Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> (SD) wrote:

>SD> Ambiguity essentially boils down to being unable to reasonably predict 
>SD> the expectation of the coder. I say "reasonably", because if you allow 
>SD> unreasonable situations, everything is "ambiguous":

That's for me the reason that len(42) is ambiguous. The OP apparently
had 1 as expectation, whereas my first thought was the minimal number of
bits to represent the number and 7.5 million came later :=). The number
of bits I certainly find reasonable, and I would find the number of
decimal digits equally reasonable. More so than 1, actually. 1 as the
length of an int doesn't give any information.
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org

More information about the Python-list mailing list