[Jeremy] > > This violates the Python C style by putting an assignment in a conditional. [Jim] > Where is this documented? Assignments in conditionals are used widely > in the C sources, including such places as gcmodule.c, object.c, and > typeobject.c. It's not actually part of PEP 7 (the Python C style guidelines). It was an informal rule in PythonLabs (at least the non-Guido part of it <wink>), triggered by noting how many subtle bugs in real life ended up involving an embedded-in-a-conditional assignment. I don't run around getting rid of those for their own sake, but if I'm rewriting a piece of code for other reasons it's a transformation I routinely make now. And you can count the number of Python bugs traced to my C code over the last decade on one finger <wink -- but avoiding doing multiple things on a single line really helps, and so does avoiding side effects in the interior of expressions>.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4