len() should always return something
Piet van Oostrum
piet at cs.uu.nl
Sat Jul 25 04:03:58 EDT 2009
>>>>> Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> (S) wrote:
>S> Chris, I'm curious why you think that these Zen are relevant to the OP's
>S> complaint.
>S> Re explicit vs implicit, len(42) is just as explicit as len([42, 23]).
>S> Arguably (I wouldn't argue this, but some people might) ints aren't
>S> "special enough" to break the rule that len(obj) should always return
>S> something.
>S> (I don't actually agree, but some people might be able to produce a
>S> coherent argument why len() should apply equally to all objects.)
>S> Re errors passing silently, the OP doesn't believe that len(42) should be
>S> an error, so that's not relevant.
>S> And there's nothing ambiguous about len(42).
len(42) should be 7.5 million.
--
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