variable substitution
Erik Max Francis
max at alcyone.com
Wed Apr 24 16:24:10 EDT 2002
Hugh wrote:
> How do I get the %(variable)s thing to work. I need to substitute a
> variable into a print statement so I can send links with sessionId's
> attached back to the browser. I'm trying this at the moment, and It
> says invalid sysntax.
> print '<a href = "addItemType.py?sessionID=%(sessionId)s">Add Item
> Type</a>'
print 'blah blah %(sessionId)s" % {'sessionId': 'ghlahglahg'}
If you really want everything in your locals stuffed in there, then call
print 'blah blah %(sessionId)s" % locals()
although you should beware of security issues if the formatting string
is coming from somewhere else.
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/ \ Life is one long process of getting tired.
\__/ Samuel Butler
Interstelen / http://www.interstelen.com/
A multiplayer, strategic, turn-based Web game on an interstellar scale.
More information about the Python-list
mailing list