[Python-ideas] Python Users Aren't Perfect

Antoine Pitrou solipsis at pitrou.net
Mon Dec 12 14:07:58 CET 2011

On Mon, 12 Dec 2011 08:00:28 -0500
Ned Batchelder <ned at nedbatchelder.com>
> On 12/10/2011 9:42 AM, Oleg Broytman wrote:
> > On Sat, Dec 10, 2011 at 02:16:21PM +0000, Richard Prosser wrote:
> >> Although I love Python there are some aspects of the language design which
> >> are disappointing and which can even lead to problems in some cases.
> >     What really is disappointing is the number of people who criticize
> > Python without knowing it.
> >
> >> Another awkward 'feature' is the requirement for a trailing comma in
> >> singleton tuples, due I believe to the use of expression parentheses rather
> >> than (say) the use of special brackets like chevrons.
> >     You do not understand the syntax. Parens do not construct tuples -
> > commas do. So for every tuple - even of length 1 - you must have a
> > comma. The only exception is an empty tuple (of length 0).
> I don't think we have to go as far as blaming the user.  Tuple syntax is 
> a little tricky, people often trip up on (x,) as a single-item tuple.  
> You and I understand why it is, and there isn't a better alternative, 
> but that one-item syntax sticks out when compared to the others: (), (x, 
> y), (x, y, z), etc.  This is a true "gotcha" as Richard originally 
> expressed it.

I think it would be more of a gotcha if parentheses were enough to
create a tuple, though. Parentheses are useful to group operations,
either for stylistic / syntactic support (think multi-line statements),
or to work around operator precedence. Creating a tuple by mistake
because you put some parentheses where not necessary would be really



More information about the Python-ideas mailing list