len() should always return something

Chris Rebert clp2 at rebertia.com
Sat Jul 25 19:30:44 EDT 2009


On Sat, Jul 25, 2009 at 4:21 PM, Erik Max Francis<max at alcyone.com> wrote:
> Steven D'Aprano wrote:
>>
>> But it's not "practically every function". It's hardly any function at all
>> -- in my code, I don't think I've ever wanted this behavior. I would
>> consider it an error for function(42) and function([42]) to behave the same
>> way. One is a scalar, and the other is a vector -- they're different things,
>> it's poor programming practice to treat them identically.
>>
>> (If Matlab does this, so much the worse for Matlab, in my opinion.)
>
> There's actually good reason to do this in heavily matrix-oriented
> specialized languages; there are numerous applications where scalars and 1x1
> matrices are mathematically equivalent.

The pertinent issue here being that Python, as a language, is neither
matrix-oriented nor special-purpose. :)

Cheers,
Chris
-- 
http://blog.rebertia.com



More information about the Python-list mailing list