<html>
<body>
At 06:56 PM 4/20/2005, PFraterdeus wrote:<br>
<blockquote type=cite class=cite cite="">Here'a little py script for a
plone page template...<br>
I just want to translate the 'key' (organicnews) to a 'value' (Organics
in the<br>
News), for presentation purposes. (the key, of course, is in the URL
request)<br><br>
<br>
db = request.db<br><br>
if db==&quot;organicnews&quot;:&nbsp; <br>
&nbsp;print &quot;%s&quot; % html_quote('Organics in the News')<br>
elif db==&quot;ovnews&quot;:<br>
&nbsp;print &quot;%s&quot; % html_quote('Our Stuff in the News')<br>
elif db==&quot;pressreleases&quot;:<br>
&nbsp;print &quot;%s&quot; % html_quote('Press Releases')<br>
else:<br>
&nbsp;print &quot;Unknown News Database!&quot;,<br>
&nbsp;print &quot;%s&quot; % db<br>
return printed</blockquote><br>
Use a dictionary:<br><br>
responses = {&quot;organicnews&quot;: &quot;Organics in the News'&quot;,
&quot;ovnews&quot; : &quot;'Our Stuff in the News'&quot;,
&quot;pressreleases&quot; : &quot;'Press Releases'&quot;}<br>
print html_quote(responses.get(db, &quot;Unknown News Database! &quot; +
db))<br><br>
BTW there is no benefit to print '%s' % blahblah. print blahblah does the
same thing.<br><br>
<blockquote type=cite class=cite cite="">[snip]<br>
I know there's a proper way to do this with a tuple, or something 
:)<br>
For the three values, it's not a problem, but if I want to scale up to
many, I<br>
imagine the dictionary is the way to go...</blockquote>
<x-sigsep><p></x-sigsep>
<font size=2>Bob Gailer<br>
<a href="mailto:bgailer@alum.rpi.edu" eudora="autourl">mailto:bgailer@alum.rpi.edu<br>
</a>510 558 3275 home<br>
720 938 2625 cell</font> </body>
</html>