Parens do create a tuple

Chris Angelico rosuav at gmail.com
Sun Apr 10 21:04:17 EDT 2016


On Mon, Apr 11, 2016 at 10:57 AM, Ben Finney <ben+python at benfinney.id.au> wrote:
> Chris Angelico <rosuav at gmail.com> writes:
>
>> On Mon, Apr 11, 2016 at 10:45 AM, Ben Finney <ben+python at benfinney.id.au> wrote:
>> > So the expanation that remains true when you examine it is: People
>> > wanted a literal syntax to create a zero-length tuple. A pair of parens
>> > is that literal syntax, and it's the parens that create the (empty)
>> > tuple.
>>
>> But parens do NOT create a one-element tuple, and that's usually where
>> people trip up.
>
> So let's stop saying “parens do not create a tuple”, because that's just
> wantonly creating *another* stubling block.

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?

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

ChrisA



More information about the Python-list mailing list