len() should always return something

Carl Banks pavlovevidence at gmail.com
Sat Jul 25 01:44:04 EDT 2009


On Jul 24, 6:57 am, Grant Edwards <invalid at invalid> wrote:
> On 2009-07-24, Dr. Phillip M. Feldman <pfeld... at verizon.net> wrote:
>
>
>
> > Some aspects of the Python design are remarkably clever, while
> > others leave me perplexed. Here's an example of the latter:
> > Why does len() give an error when applied to an int or float?
> > len() should always return something; in particular, when
> > applied to a scalar, it should return a value of 1.
>
> If len(7) returned a value of 1, then wouldn't one expect 7[0]
> to be valid?  It isn't, so you'd then have to redefine all
> types so that they are sequences that can be indexed.  Sounds
> like a big mess to me...

You can call the big mess "Matlab".


Carl Banks



More information about the Python-list mailing list