[python 2.4] unable to construct tuple with one item
Vyacheslav Maslov
slava.maslov at gmail.com
Sun May 6 08:23:54 EDT 2007
Hi, all!
I found out different behavior of python interpeter related to tuples and
lists with one item only.
I have simple example
>>> print type(())
<type 'tuple'>
it's ok, we have just constructed empty tuple
>>> print type((4))
<type 'int'>
but when i add exactly one item to my tuple i get atomaric int instead of
tuple!!! why?
>>> print type((4,))
<type 'tuple'>
this problem can be avoided by adding comma after first item
>>> print type([4])
<type 'list'>
but finally, python constructs list with one item without any problem.
So, the main question is why using syntax like [X] python constuct list with
one item, but when i try to construct tuple with one item using similar
syntax (X) python do nothing?
P.S. python 2.4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070506/95454490/attachment.html>
More information about the Python-list
mailing list