Howdy!

>> This works even without adding web.cond to template globals:
>>  <div class="$(sunny and 'yellow' or 'grey')">...</div>
> 
> Oh. Now, that's a cool hack. Big thumbs up! I guess I have to brush my Python 
> up. :P

Only concern with that syntax is that both the true and false expressions are 
evaluated regardless of the state of the conditional, vs. the Python 2.5+ 
syntax of:

        $('yellow' if sunny else 'grey')

Which only evaluates one or the other.  This is important if your conditional 
tests for the presence of a property and either uses it, or doesn’t, to avoid 
attribute errors.  (One example of several where the A and B or C syntax fails.)

        — Alice.

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to