Variables in strings..
Aahz Maruch
aahz at netcom.com
Mon Jul 24 10:29:57 EDT 2000
In article <81324605608.20000724121203 at buz.ch>,
Gabriel Ambuehl <gabriel_ambuehl at buz.ch> wrote:
>
>print "Hello %(name)s" % var()
I much prefer writing code to build a dict and then using that. Here's
an example:
dict = { 'foo': 'xyz', 'bar': 'pdq' }
print "Hello %(foo)s, %(bar)s" % dict
Doesn't help much with your array slices, directly, but you could easily
create a class with a __str__() method.
--
--- Aahz (Copyright 2000 by aahz at netcom.com)
Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6
Zie is so far from a clue that it would take a sub-light vessel several
years to reach one. --Aahz
More information about the Python-list
mailing list