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::
_expr1 = expr1
if _expr1 is not None:
value1 = _expr1.field.of.interest
if expr1 is not None:
value1 = expr1.field.of.interest
else:
value1 = None
_expr2 = expr2
if _expr2 is not None:
value2 = _expr2["field"]["of"]["interest"]
if expr2 is not None:
value2 = expr2["field"]["of"]["interest"]
else:
value2 = None
_expr3 = expr3
if _expr3 is not None:
value3 = _expr3
if expr3 is not None:
value3 = expr3
else:
_expr4 = expr4
if _expr4 is not None:
value3 = _expr4
if expr4 is not None:
value3 = expr4
else:
value3 = expr5