[Zope] conditionals inside dtml-let expressions
Mitchell L Model
mlm@acm.org
Thu, 18 Oct 2001 21:57:12 -0400
>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