Re: [Zope] conditionals inside dtml-let expressions
19 Oct
2001
19 Oct
'01
1:57 a.m.
On Thursday 18 October 2001 12:56 pm, Mitchell Model allegedly wrote:
Is there a straightforward way to bind one of two values to a let variable depending on the value of another variable? In C/C++/Java I would use the ?: operator, but Python doesn't have that. Or should I just bind the variable to None then set it later with something like
<dtml-let var=None>
<dtml-if "testvar==targetval">
<dtml-var expr="_.set(var, 'yes')>
<dtml-else>
<dtml-var expr="_.set(var, 'no')>
</dtml-if>
</dtml-let>
Perhaps:
<dtml-let var="['no','yes'][testvar==targetval]"> ... </dtml-let>
Ah, yes -- that's the Python idiom I was looking for. It's so weird, I can never remember it! Thanks. -- --- Mitchell
8936
Age (days ago)
8936
Last active (days ago)
0 comments
1 participants
participants (1)
-
Mitchell L Model