Terry Reedy wrote:
> "Nick Coghlan" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> | More completely:
> |
> |      ()           # empty tuple
> |      (1,)        # 1 item tuple
> |      (1,2)      # 2 item tuple
> 
> 1,    # 1 item tuple, no parens needed, trailing comma mandatory
> 1,2  # 2 item tuple, no parens needed
> 1,2, # 2 item tuple with optional trailing comma

No parens needed, unless the comma would be interpreted as meaning 
something else if the parens were left out (function argument separator, 
name separator in a 2.x series except clause, item separator in a 
surrounding tuple/list/dict definition, etc), or if the first expression 
would be overinclusive without them (e.g. string formatting with %). A 
lot of the time I find it easier to just include the parentheses instead 
of worrying about it (they're kind of like yield expressions that way...).

Anyway, for the kind of stylistic comparison I was talking about in the 
previous post, I think it is useful to think of the parentheses as part 
of the tuple syntax (because that's the way they are often written), 
even though that isn't completely correct in terms of the language's 
grammar.

We've veered pretty far from the original topic now though, so it would 
probably be best to drop the mailing list from any further discussion :)

Cheers,
Nick.

-- 
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to