PEP308: Yet another syntax proposal
Raymond Hettinger
vze4rx4y at verizon.net
Mon Feb 10 12:48:40 EST 2003
> "Aahz" <aahz at pythoncraft.com>
> > I still have yet to see a clear explanation of why short-circuit is
> > necessary and therefore iif() unreasonable.
>
> It is necessary when:
> 1. One of the alternatives has a side-effect; or
> 2. one or both alternatives are time consuming; or
> 3. the validity of the alternatives depends on the outcome
> of the test.
>
> # Example where all three reasons apply
> data = isinstance(source, str) ?? source.readlines() ||
source.split()
That should have been:
isinstance(source, file)
Raymond Hettinger
More information about the Python-list
mailing list