Stupid string formatting question

Andreas Jung andreas at andreas-jung.com
Thu May 16 21:32:32 EDT 2002


It would be counter-intuitive if Python would work in the way you
would like it. There is a 1:1 relationship between the placeholders
in the format string and the values. Another behaviour would be ambigious
and is not desirable.

-aj

----- Original Message -----
From: "Michael S. Fischer" <michael+usenet at dynamine.net>
Newsgroups: comp.lang.python
To: <python-list at python.org>
Sent: Thursday, May 16, 2002 21:19
Subject: Stupid string formatting question


> 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.
>
> --
> Michael S. Fischer / michael at dynamine.net / +1 650-533-4684
> Lead Hacketeer, Dynamine Consulting, Silicon Valley, CA
> --
> http://mail.python.org/mailman/listinfo/python-list
>






More information about the Python-list mailing list