As part of my series on Python's syntactic sugar, I initially skipped tackling conditional expressions because I made them more complicated than I needed to in my head.😅 But there is some key subtlety to unravelling them which may not be obvious.Let's start with a simple example of an assignment expression inside of a function call:
Example Python code of an assignment expression inside of a function call Now naively you might think you can just lift that assignment expression out to be an assignment statement and things would just work, like so:
Naively moving the assignment expression out of the function call's parameter list Unfortunately this doesn't work for more complicated examples.
Example Python code of an assignment expression inside of a function call Now naively you might think you can just lift that assignment expression out to be an assignment statement and things would just work, like so:
Naively moving the assignment expression out of the function call's parameter list Unfortunately this doesn't work for more complicated examples.
[
add
]
[
|
|
...
]