[Python-Dev] Is PEP 572 really the most effective way to solve the problems it's targeting?
Steven D'Aprano
steve at pearwood.info
Thu Apr 26 00:03:32 EDT 2018
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.
> 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 ...
--
Steve
More information about the Python-Dev
mailing list