A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-February/033255.html below:

[Python-Dev] vox populii illiterati

[Python-Dev] vox populii illiteratiAndrew Koenig ark@research.att.com
09 Feb 2003 22:58:04 -0500
Samuele> From: "holger krekel" <pyth@devel.trillke.net>
>> 
>> if obj.method() if hasattr(obj, 'method') else False:
>> 

Samuele> don't worry the pro-camp seems converging toward:

Samuele> if if hasattr(obj,'method'): obj.method() else: False:

Samuele> or

Samuele> if (if hasattr(obj,'method'): obj.method() else: False):

I count myself in the pro-camp, and I would prefer

        if hasattr(obj,'method') and obj.method():

to any of the alternatives, for the obvious reason.  In fact, as a
pragmatic note, I wouldn't mind it if the compiler gave a warning
about

        if <cond>: True else: <expr>

or

        if <cond>: <expr> else: False

because they're equivalent to

        bool(cond) or <expr>

and

        bool(cond) and <expr>

respectively.


-- 
Andrew Koenig, ark@research.att.com, http://www.research.att.com/info/ark



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4