text processing: variable interpolation and more

Greg Weeks weeks at vitus.scs.agilent.com
Sun Sep 9 13:17:29 EDT 2001


Oleg Broytmann (phd at phd.pp.ru) wrote:
: print "Dear %(recipient)s:" % dict  ...

:    will extract dict[recipient] and put it into the string as string. More
: details in Python docs about overloaded operator %.

Thanks.  I (obviously) was only aware of (s % d) with d a tuple, despite
the fact that my textbook describes both cases in the same sentence.  Oops!

Still, with *two* dictionaries you can capture the entire scope.  Or,
rather, you could in 1.5.2.

Thanks again,
Greg



More information about the Python-list mailing list