On Nov 4, 2006, at 11:14 AM, Jonathan Ellis wrote:
This means you pretty much have to
use and/or for inline conditionals, as far as I know.

you can do this with boolean operators in early python versions

a = condition and trueval or falseval


Right, that's what I meant by 'use and/or for inline conditionals' in the above statement, and it's what the code I was responding to did.

this doesn't quite work if trueval happens to evaluate to false, so in
python 2.5 you can write

a = trueval if condition else falseval

Cool, I didn't know about that. Haven't been paying too much attention to Python lately, and the python I've got on this box isn't up to date. It's definitely nicer to have a conditional expression than to have to rely on the short-circuit behavior of boolean expressions.

                --Levi

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to