3 ms·
By side effects of the assignment, what specific side effects are you referring to exactly? Or just the fact that assignment is happening inside of an expressi
by tedmiston 8y ago
By side effects of the assignment, what specific side effects are you referring to exactly? Or just the fact that assignment is happening inside of an expression?
I saw an edge case in scope around lambdas in the PEP, but not sure if that's what you're getting at.
- mlthoughts2018 8y agoI mean that the phenomenon of assignment happens as a side-effect of an expression. Just look at PEP 572 and consider the huge number of examples it gives where it says “valid, but not great style” or “valid but confusing” or “valid but probably never useful.” It’s bewildering to read, and this is in the highly controlled environment of the very PEP that defines it! Imagine how inscrutable it would be out in the wild, whether through unanticipated confusion from well-meaning authors, or through people trying to be clever and squeeze useless one-liner concision out of it, or nesting its usage and using assignment expression inside positional argument lists all over. It’s unquestionable that this opens a Pandora’s box of problems for reasoning about code. But it is questionable exactly when or why it ever offers a serious advantage over just breaking assignment statements up into a separate line or an explicitly side-effectful function call (so it can be done inside a lambda, etc).