PEP 308: A PEP Writer's Experience - PRO

John La Rooy nospampls.jlr at doctor.com
Tue Feb 11 01:07:20 EST 2003


On Mon, 10 Feb 2003 19:28:43 -0800
Erik Max Francis <max at alcyone.com> wrote:

> Andrew Koenig wrote:
> 
> > I'm not worried about the standard-library authors misusing the
> > idiom.  I'm worried about ordinary programmers reading such code
> > and failing to realize that the idiom doesn't work all the time.
> 
> But, as Andrew's example has so deftly shown, the standard library
> authors _have_ misused the idiom.  Now imagine that idiom in the hands
> of someone not as familiar with Python as the standard library authors.
> 

I believe that is what holger was doing when he wrote this

    if obj.method() if hasattr(obj, 'method') else None:

Which you called a red herring. But this is exactly the type of abuse I imagine
we can expect when perl and C hackers come here asking the python way of saying
"c?x:y" and you tell them "x if c else y"

John





More information about the Python-list mailing list