PEP 531: simplify code expansion to match original

This commit is contained in:
Nick Coghlan 2016-10-28 18:35:53 +10:00
parent 7371998040
commit d5969080c7
1 changed files with 8 additions and 12 deletions

View File

@ -113,23 +113,19 @@ with 16 or 20 lines of conditional logic really doesn't help matters.
Expanding the three examples above that way hopefully helps illustrate that:: Expanding the three examples above that way hopefully helps illustrate that::
_expr1 = expr1 if expr1 is not None:
if _expr1 is not None: value1 = expr1.field.of.interest
value1 = _expr1.field.of.interest
else: else:
value1 = None value1 = None
_expr2 = expr2 if expr2 is not None:
if _expr2 is not None: value2 = expr2["field"]["of"]["interest"]
value2 = _expr2["field"]["of"]["interest"]
else: else:
value2 = None value2 = None
_expr3 = expr3 if expr3 is not None:
if _expr3 is not None: value3 = expr3
value3 = _expr3
else: else:
_expr4 = expr4 if expr4 is not None:
if _expr4 is not None: value3 = expr4
value3 = _expr4
else: else:
value3 = expr5 value3 = expr5