use "val1 if cond else val2" instead of "cond and val1 or val2"

Bug #1188111 reported by Kun Huang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
Fix Released
Undecided
Kun Huang

Bug Description

"cond and val1 or val2"
This is an old conditional expression and it's hard to understand because only when val1 is False it will return val2.

Using "val1 if cond else val2" is much understandable.

More talks here:

[0] http://stackoverflow.com/questions/394809/ternary-conditional-operator-in-python
[1] http://www.python.org/dev/peps/pep-0308/

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to swift (master)

Fix proposed to branch: master
Review: https://review.openstack.org/31943

Changed in swift:
assignee: nobody → Kun Huang (academicgareth)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (master)

Reviewed: https://review.openstack.org/31943
Committed: http://github.com/openstack/swift/commit/157f61651ea740cf6d827a3ce82f153b6fcd1e6e
Submitter: Jenkins
Branch: master

commit 157f61651ea740cf6d827a3ce82f153b6fcd1e6e
Author: Kun Huang <email address hidden>
Date: Thu Jun 6 17:59:31 2013 +0800

    Remove <cond> and <val1> or <val2> systax

    Use <val1> if <cond> else <val2> instead.
    There're more talks:
    [0] http://stackoverflow.com/questions/394809/ternary-conditional-operator-in-python
    [1] http://www.python.org/dev/peps/pep-0308/

    Fixes bug 1188111

    Change-Id: I485e674317faf319a26ab30c2c193d8464a7e46e

Changed in swift:
status: In Progress → Fix Committed
Changed in swift:
milestone: none → 1.9.0
Thierry Carrez (ttx)
Changed in swift:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.