Extra comma
Oren Tirosh
oren-py-l at hishome.net
Wed Feb 12 09:25:11 EST 2003
On Thu, Feb 13, 2003 at 02:50:11AM +1300, Paul Foley wrote:
> On Thu, 13 Feb 2003 01:29:42 +1300, Paul Foley wrote:
>
> > On Wed, 12 Feb 2003 05:10:00 -0500, Oren Tirosh wrote:
> >> There is a slight inconsistency in Python in that it doesn't allow a
> >> trailing comma in an empty list, tuple or argument list. 1-tuples REQUIRE
> >> a comma and 0-tuples FORBID a comma. If would have been more consistent
> >> to always allow a trailing comma.
>
> > That wouldn't even make /sense/, let alone being "more consistent".
>
> Hmm. That didn't come out right. In fact, it does make sense, and it
> /is/ allowed:
>
> 1,
> 1,2,
> 1,2,3,
>
> etc., are perfectly legal 1-, 2-, and 3-tuples. You obviously can't
> have a 0-tuple with a comma, though.
It would require parentheses, just like 0-tuples currently do:
(,) <- currently not allowed, but could be.
(1,)
(1,2,)
(1,2,3,)
()
(1) <- not allowed, for obvious reasons.
(1,2)
(1,2,3)
I'm not actually proposing this as a language feature, just pointing it
out.
Oren
More information about the Python-list
mailing list