Arithmetic sequences in Python

Paul Rubin http
Thu Jan 19 00:00:09 EST 2006

aleax at (Alex Martelli) writes:
> > Well, [...] notation for regular lists (as opposed to list
> > comprehensions) is also unnecessary since we could use "list((a,b,c))".
> Indeed, there's no reason list couldn't accept multiple arguments as an
> alternative to one sequence argument, just like min and max.  This would
> make list(a, b, c) work just perfectly.

What should the output of "print list(1,2,3)" be?  Is there a really
good reason to make it different from the input syntax?

What should list(list(1,2,3)) be?  Should "list" really work
completely differently depending on whether it has a single arg or
multiple args?

How would you make a one-element list, which we'd currently write as [3]?
Would you have to say list((3,))?

> I see no credibly simple and readable alternative to {a:b, c:d}
> dictionary display syntax, for example; dict(((a,b),(c,d))) just
> wouldn't cut it, because of the "parentheses overload" (double
> entendre intended).


I don't really see why keyword arg names have to be identifiers
either.  foo(3=4) can pass a **kwargs containing {3:4}.

> 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).

That's subjective at best.  Even Scheme doesn't make you use
extra keywords to write something as fundamental as a list.  ;-)

> 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.

Well, what's supposed to happen when you print a list then?

More information about the Python-list mailing list