Tuple "detection"

Batista, Facundo FBatista at uniFON.com.ar
Mon May 19 13:06:16 EDT 2003


I can do:

>>> x = range(2)
>>> x
[0, 1]
>>> x, y = range(2)
>>> x
0
>>> y
1
>>>

When I write 'x, y = range(2)',  I'm building a tuple that gets the
assignment?

It's the same to write:

>>> (x, y)  = range(2)

Everything allright by now (or not?).


But when I write 

>>> print "%d %d" % (5, 5)
5 5

It's not the same to write:

>>> print "%d %d" % 5, 5
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: not enough arguments for format string


Is this on purpose? Why?

I'm working on Python 2.1.1.

Thanks for all!!

Facundo Batista
Gestión de Red
fbatista at unifon.com.ar
(54 11) 5130-4643
Cel: 15 5132 0132







More information about the Python-list mailing list