PEP 308: A PEP Writer's Experience - PRO
pyth at devel.trillke.net
Tue Feb 11 00:53:24 CET 2003
David Eppstein wrote:
> In article <mailman.1044904883.10775.python-list at python.org>,
> holger krekel <pyth at devel.trillke.net> wrote:
> > People using the ternary-op may easily fail to realize
> > that the idiom isn't the right one all the time. For example,
> > it might prevent people from learning about the specific pythonic
> > behaviour of and/or returning the "short-circuiting" object.
> > Subsequently
> > result = hasattr(obj, 'method') and obj.method()
> > is not obvious to them but
> > result = obj.method() if hasatttr(obj, 'method') else None
> > is
> I fail to see why forcing people to avoid an idiom that's obvious to
> them (because it's not the "right" one) is a benefit to their
> productivity or the readability of their code.
because it easily leads to
if obj.method() if hasattr(obj, 'method') else None:
which you have a harder time to justify as nice, not?
More information about the Python-list