3 ms·
I 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 wher
by mlthoughts2018 8y ago
I 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).