len() should always return something

Erik Max Francis max at alcyone.com
Sat Jul 25 21:47:07 EDT 2009


Chris Rebert wrote:
> 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. :)

Yes.  And I was responding to the comment that such a feature of a 
language would a priori be poor design.  It _isn't_ poor design for 
special purpose languages.  Python isn't one of them, but Matlab _is_.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis
   More fodder for the new lost generation
    -- Nik Kershaw



More information about the Python-list mailing list