Closed MartinThoma closed 3 years ago
astpretty --no-show-offsets /dev/stdin <<< `cat example.py`
Module(
body=[
If(
test=Name(id='a', ctx=Load()),
body=[
Assign(
targets=[Name(id='b', ctx=Store())],
value=Name(id='c', ctx=Load()),
type_comment=None,
),
],
orelse=[
Assign(
targets=[Name(id='b', ctx=Store())],
value=Name(id='d', ctx=Load()),
type_comment=None,
),
],
),
],
type_ignores=[],
)
Explanation
Use the ternary operator if it's reasonable.
Example