[New-bugs-announce] [issue2817] Make Python create a tuple with one element in a clean way

Chester report at bugs.python.org
Sun May 11 15:16:17 CEST 2008


New submission from Chester <wxpythoner at gmail.com>:

To create a tuple with one element, you need to do this:

>>> my_tuple = (1,)    # Note the trailing comma after the value 1
>>> type(my_tuple)
<type 'tuple'>


But if you do this

>>> my_tuple = (1)
>>> type(my_tuple)
<type 'int'>

you don't get a tuple. I thought that just putting a value inside ( )
would make a tuple. Apparently that is not the case. I hate ugly code
so it would be clean if Python would convert anything put into ( ) to
be a tuple, even if just one value was put in (without having to use
that ugly looking comma with no value after it).

----------
messages: 66626
nosy: chester
severity: normal
status: open
title: Make Python create a tuple with one element in a clean way
type: feature request
versions: 3rd party, Python 2.1.1, Python 2.1.2, Python 2.2, Python 2.2.1, Python 2.2.2, Python 2.2.3, Python 2.3, Python 2.4, Python 2.5, Python 2.6, Python 3.0

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2817>
__________________________________


More information about the New-bugs-announce mailing list