Parens do create a tuple

Ben Finney ben+python at benfinney.id.au
Sun Apr 10 21:41:52 EDT 2016


Chris Angelico <rosuav at gmail.com> writes:

> Fair enough. Let's instead say "commas create tuples", which is true
> in all cases except the singleton empty tuple. Is that near enough
> that we can avoid the detail?

It's a fine thing to say, because it's simply true. Commas create
tuples.

There are some tuples that cannot be created as a literal by comma. That
does not make the statement untrue.

They are not the *only* thing that creates tuples; parens can also
create tuples. So we should avoid false statements on that score.

> I'd rather be correct on the one-element case and wrong on the empty
> than the other way around.

To say “commas create tuples” is to say an unobjectionably true
statement about Python syntax. It remains true as one continues to learn
Python.

To say “parens do not create tuples” is to lay a trap which needs to be
de-fused at some point. Better IMO never to lay that trap.

-- 
 \         “It’s a great idea to come in unencumbered by dogma but you |
  `\        can’t also be unencumbered by evidence.” —Darren Saunders, |
_o__)                                                       2015-12-02 |
Ben Finney




More information about the Python-list mailing list