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
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to