Re: unable to construct tuple with one item

2007-05-06 Thread Vyacheslav Maslov
Guys, thanks a lot for you answers -- http://mail.python.org/mailman/listinfo/python-list

Re: unable to construct tuple with one item

2007-05-06 Thread Steven D'Aprano
On Sun, 06 May 2007 14:26:46 -0700, MRAB wrote: > If it's the comma that makes the tuple, then wouldn't [1, 2] make a 2- > tuple in a list, ie == [(1, 2)]? Hmm... Yes, Python creates the tuple 1,2 and then the square brackets turn it into a list. I doubt the Python compiler is actually so ineff

Re: unable to construct tuple with one item

2007-05-06 Thread MRAB
On May 6, 4:04 pm, Mel Wilson <[EMAIL PROTECTED]> wrote: > Vyacheslav Maslov wrote: > > 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? > > Because `(` and

Re: [python 2.4] unable to construct tuple with one item

2007-05-06 Thread Mel Wilson
Vyacheslav Maslov wrote: > 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? Because `(` and `)` are used in expressions to bracket sub-expressions. a = (4 + 3)

Re: [python 2.4] unable to construct tuple with one item

2007-05-06 Thread Facundo Batista
Vyacheslav Maslov wrote: > 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? Because what determines that you actually have a tuple is the comma, not the parenthesi

[python 2.4] unable to construct tuple with one item

2007-05-06 Thread Vyacheslav Maslov
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(()) it's ok, we have just constructed empty tuple print type((4)) but when i add exactly one item to my tuple i get atomaric int instead of tuple!!