[Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part) (original) (raw)
Ivan Pozdeev vano at mail.mipt.ru
Wed Jun 27 06:00:31 EDT 2018
- Previous message (by thread): [Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)
- Next message (by thread): [Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 26.06.2018 1:34, Greg Ewing wrote:
Ivan Pozdeev via Python-Dev wrote:
"as" was suggested even before is became a keyword in `with'. ( if (re.match(regex,line) as m) is not None: ) That's not equivalent where/given, though, since it still has the asymmetry problem. What do you mean by "asymmetry"? The fact that the first time around, it's the expression and after that, the variable?
If that, it's not a "problem". The whole idea is to assign the result of a subexpression to something. If you force any assignments to be outside, it won't be a subexpression anymore, but effectively a separate statement -- if not syntactically, then visually at least -- both of which are the things the feature's purpose is to avoid.
If you seek to force assignments outside, you should've rather suggested inline code blocks e.g. like anonymous methods in C# ( { a=foo(); b=bar(); return a+b;} ).
Using this assigned result elsewhere in the same expression (akin to regex backreferences) is not a part of the basic idea actually. It depends on the evaluation order (and whether something is evaluated at all), so I doubt it should even be allowed -- but even if it is, it's a side benefit at best.
-- Regards, Ivan
- Previous message (by thread): [Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)
- Next message (by thread): [Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]