[Tutor] using a dictionary??
peterf at mac.com
Thu Apr 21 03:56:25 CEST 2005
Here'a little py script for a plone page template...
I just want to translate the 'key' (organicnews) to a 'value' (Organics in the
News), for presentation purposes. (the key, of course, is in the URL request)
db = request.db
print "%s" % html_quote('Organics in the News')
print "%s" % html_quote('Our Stuff in the News')
print "%s" % html_quote('Press Releases')
print "Unknown News Database!",
print "%s" % db
This script works fine as is, no problem... BUT
I know there's a proper way to do this with a tuple, or something :)
For the three values, it's not a problem, but if I want to scale up to many, I
imagine the dictionary is the way to go...
Thanks for hints on a proper pythonesque and elegant syntax for this pattern!
More information about the Tutor