On Wed, Jul 4, 2018 at 12:26 AM Nathaniel Smith <njs at pobox.com> wrote: > The only cases that seem potentially valuable to me are the ones that > are literally the form 'if <name> := <expr>` and 'while <name> := > <expr>'. (I suspect these are the only cases that I would allow in > code that I maintain.) The PEP does briefly discuss the alternative > proposal of restricting to just these two cases, but rejects it > because it would rule out code like 'if (<name> := <expr>) > <comparison> <expr>'. But those are exactly the cases that I want to > rule out, so that seems like a plus to me :-). The PEP doesn't talk about it, but FWIW, Go and C++17 if statements allow you to put arbitrary simple statements in the suite header, and by doing that, solves all the issues you and the PEP mentioned. In Python it'd look like this: if x = expr(); x < 0: do_stuff() (and presumably, the same for while: "while line = f.readline(); line: ...") -- Devin
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