Arithmetic sequences in Python

André andre.roberge at gmail.com
Wed Jan 18 23:37:35 EST 2006


Alex Martelli wrote:
> Paul Rubin <http://phr.cx@NOSPAM.invalid> wrote:
>    ...
> > Well, [...] notation for regular lists (as opposed to list
> > comprehensions) is also unnecessary since we could use "list((a,b,c))".
>
[snip]     ... or should that be list(snip)?
>  But
> list has no such problem, and there's really no added value of clarity
> and readability in [a,b,c] vs list(a,b,c).  And don't tell me that the
> added value is that brackets "suggest lists", since they're used to
> index tuples and dicts just as well;-).  So the only reason they may
> "suggest lists" is that you're used to that display form in Python, but
> there's no real reason to HAVE a display form for lists at all, IMHO.
>
> Alex

I'm reading this and thinking "I disagree (?!) with Alex Martelli;
[a,b,c] is so much easier to read and understand than list(a,b,c)"...

And then it dawned on me that, the first time I learned about list
comprehension (a little over a year ago, in A.M.'s Python in a
Nutshell), I had all kinds of trouble getting used to seeing right away
that the square brackets were an indication that a list was created.
At the time, I would have totally agreed that list(a,b,c) is *much*
clearer...
{or expressions like a = list(x for x in range(1)) ...}

*Now*, I prefer [], as I have been "trained" that way... but, thinking
back, and thinking about teaching Python, I'd have to agree with Alex's
point (not that anyone would care about *my* opinion ;-)

André




More information about the Python-list mailing list