Stupid string formatting question
Michael S. Fischer
michael+usenet at dynamine.net
Thu May 16 21:58:54 EDT 2002
On Fri, 17 May 2002 02:40:27 +0100, Gonçalo Rodrigues
<op73418 at mail.telepac.pt> wrote:
>>Why can't I do this?
>>
>> def foo(x):
>> # Do some operations on x yielding a and b
>> return a, b
>>
>> print "a = %s, b = %s" % (foo(x))
>>
>>It seems counter-intuitive that although foo is defined to return a 2-item
>>tuple, the interpreter just doesn't get it.
>
> There must be something you are not telling us. It works fine for me,
OK, here's an example.
>>> def x():
... return "a", "b"
...
>>> print "%s/%s/%s/%s" % ("hi", "there", x())
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: not enough arguments for format string
--
Michael S. Fischer / michael at dynamine.net / +1 650-533-4684
Lead Hacketeer, Dynamine Consulting, Silicon Valley, CA
More information about the Python-list
mailing list