[issue24901] (2, )!=(2) and (2, 3)==(2, 3, ) why ??? tested in each version

2015-08-20 Thread eryksun

eryksun added the comment:

Refer to section 6.2.3, parenthesized forms:

https://docs.python.org/3/reference/expressions.html#parenthesized-forms

if the list contains at least one comma, it yields a tuple;
otherwise, it yields the single expression that makes up the
expression list.

So (2) is an int, while (2,) is a tuple that contains an int.

The exception is the empty tuple, for which parentheses are
required — allowing unparenthesized “nothing” in 
expressions would cause ambiguities and allow common typos
to pass uncaught.

Thus () is an empty tuple. Note also that section 6.13 states the following 
regarding a trailing comma:

The trailing comma is required only to create a single 
tuple (a.k.a. a singleton); it is optional in all other 
cases.

--
nosy: +eryksun
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24901] (2, )!=(2) and (2, 3)==(2, 3, ) why ??? tested in each version

2015-08-20 Thread shiva prasanth

Changes by shiva prasanth :


--
nosy:  -shivaprasanth
title: single element tuple 's ending comma is different that without comma -> 
(2,)!=(2) and (2,3)==(2,3,) why ??? tested in each version
type:  -> behavior
versions: +Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com