PEP 308: A PEP Writer's Experience - PRO

Erik Max Francis max at
Tue Feb 11 09:28:01 CET 2003

John La Rooy wrote:

> 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"

Using a conditional operator as the sole expression in the conditional
of an if statement is pretty bad style in any language.  My point about
it being red herring is that this is simply a general style issue in any
language, not just Python.  I suspect that its use will be very rare in
Python, just like it is in C, C++, Java, or Perl.

 Erik Max Francis / max at /
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ I always entertain great hopes.
\__/ Robert Frost
    REALpolitik /
 Get your own customized newsfeed online in realtime ... for free!

More information about the Python-list mailing list