[Python-Dev] Is PEP 572 really the most effective way to solve the problems it's targeting?

Ryan Gonzalez rymg19 at gmail.com
Thu Apr 26 00:23:36 EDT 2018


On April 25, 2018 11:05:04 PM Steven D'Aprano <steve at pearwood.info> wrote:

On Wed, Apr 25, 2018 at 09:36:31PM -0500, Ryan Gonzalez wrote:
<opinion>

I have to say I'm not overly thrilled with PEP 572...it's almost odd,
because if you asked me back when I first joined this list when I was 13, I
would've no doubt said *YES*.

I have the opposite experience: I've warmed to it the more I have read
it. Before Chris had even written this PEP, there was a Python-Ideas
thread asking for dedicated syntax in comprehensions alone that would
have been equivalent to a binding-expression. I was rather negative
about the whole thing (but no where near as negative as I've been in
the past when this has come up before), until Chris pointed out that
such binding-expressions have value outside of comprehensions.


[...]
Now, what's the common theme here? **Declarations should be separate from
expressions.**

Declarations and assignments are not the same thing.

Yeah, this is what happens when I write these things when tired... I meant 
to also mention assignments here, and anywhere else I may have used 
"declaration".



We've got languages that range from baggage-filled to
functional to a bit of all of the above, and none of them have added
assignment *inside* an expression.

And your claim about assignment inside expressions is only true if you
ignore the languages where assignment is an expression with a return
value. You know, strange and exotic languages with hardly any users or
influence, like C, C++, C#, Java, Javascript, Ruby, Perl, PHP, Lisp ...

In the majority of these, however, mixing assignments into expressions is 
considered bad practice.

For instance:

- C++ core guidelines: 
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Res-complicated
- MediaWiki style guide: 
https://m.mediawiki.org/wiki/Manual:Coding_conventions/PHP

Some of the other languages (e.g. Perl) aren't some I'd regard as positive 
influences...



--
Steve
_______________________________________________
Python-Dev mailing list
Python-Dev at python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/rymg19%40gmail.com

--
Ryan (ライアン)
Yoko Shimomura, ryo (supercell/EGOIST), Hiroyuki Sawano >> everyone else
https://refi64.com/




More information about the Python-Dev mailing list