You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2015-08-20.11:03:15.981>created_at=<Date2015-08-20.10:42:08.971>labels= ['type-bug', 'invalid']
title='(2,)!=(2) and (2,3)==(2,3,) why ??? tested in each version'updated_at=<Date2015-08-20.11:03:15.948>user='https://bugs.python.org/shivaprasanth'
Python 2.7.9 (default, Apr 2 2015, 15:33:21)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> (2,)==(2)
False
>>> (2,3,)==(2,3)
True
>>> (2,3)==(2,3,)
True
>>> s=(2,)
>>> s2=(2)
>>> s==s2
False
>>>
shivaprasanthmannequin
changed the title
single element tuple 's ending comma is different that without comma
(2,)!=(2) and (2,3)==(2,3,) why ??? tested in each version
Aug 20, 2015
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.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: