What about an EXPLICIT naming scheme for built-ins?

Alex Martelli aleaxit at yahoo.com
Tue Sep 7 10:50:37 EDT 2004


Mel Wilson <mwilson at the-wire.com> wrote:

> In article <mailman.2905.1094405220.5135.python-list at python.org>,
> Alex Martelli <aleaxit at yahoo.com> wrote:
> >I don't understand why some people want to use list comprehensions
> >instead of simple calls to list().
> 
>    It's one more damned word to read.  It under-uses the

No way:

newlist = list(somegenerator())

is three words (plus five punctuation characters), while

newlist = [x for x in somegenerator()]

is six words (plus five punctuation characters).

> ability to notice visual patterns like  = [  or  +  . It's one
> step down the slope toward lisp, or to mathematics before
> algebraic notation, when everything was written out longhand
> in Greek.

If you like "visual patterns" of punctuation characters, then you want
(e.g.) Haskell, not Python -- [x | x <- xs] does indeed have few words
(well, it would be pretty silly in Haskell, of course!), though not as
few as 'list xs'.  But the Python way _DOES_ lean way more to keywords
than to punctuation, which is why we changed the vertical bars and <-
into for and in WORDS when we stol^H^H^H^H borrowed Haskell's list
comprehensions -- of course, it's easy to think of languages which are
even more oriented to verbalization (Cobol's "ADD X TO Y GIVING Z" comes
to mind), while Python tries to claim a Middle Way (hmmm, maybe APL or
its descendants are what you want if you truly loathe words -- even
Haskell does have its share of the latter, after all).

So far, publically and privately, I had only heard from people basically
saying they didn't even KNOW that list(seq) existed or worked the way it
does, or that they just don't think of it.  You appear to be the first
to advance the thesis that people know that list(seq) is just the same
thing (except way more concise, direct, and fast) than [x for x in seq]
and deliberately choose the latter for your claimed reasons (starting
with the implicit claim that such people are utterly incapable of
counting words, which I find quite curious).

Ah well, once again I'm left pining for the who-knows-when coming of
Python 3.0, when (among other things) list comprehensions will
disappear, and only generator comprehensions and the 'list' built-in
will blissfully remain.  Were it not for some dark threats about
potential added features of 3.0, its promise of important conceptual
simplification by the elimination of legacy features sounds SO sweet!


Alex



More information about the Python-list mailing list