conditional expressions (RE: Loop-and-a-half (Re: Curious assignment behaviour))

Andrew Dalke dalke at
Fri Oct 19 03:25:51 CEST 2001

Paul Rubin:
>"John Roth" <johnroth at> writes:
>> Many instances of this are already handled by the short-circuit
>> 'and' and 'or' operators.
>And that's supposed to be readable?

It can be

def f(dirname = None):
  dirname = dirname or os.eviron.get("MY_DIRNAME") or default_dirname

as compared to

  dirname = dirname ? dirname :
             (os.getenv("MY_DIRNAME") ? os.getenv("MY_DIRNAME") :

                    dalke at

More information about the Python-list mailing list