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

Antoine Pitrou solipsis at pitrou.net
Thu Apr 26 07:42:33 EDT 2018


On Thu, 26 Apr 2018 20:35:20 +0900
"Stephen J. Turnbull" <turnbull.stephen.fw at u.tsukuba.ac.jp> wrote:

> Steven D'Aprano writes:
>  > On Wed, Apr 25, 2018 at 09:36:31PM -0500, Ryan Gonzalez wrote:  
> 
>  > > Now, what's the common theme here? **Declarations should be separate from 
>  > > expressions.**  
>  > 
>  > Declarations and assignments are not the same thing.  
> 
> Ryan mostly meant "initialization" rather than "declaration", I
> suspect.  In C's for() statement, the first clause in parentheses is
> initialization, the third is assignment.
> 
> FWIW, I had been thinking the same thing (that what is really wanted
> is initialization clauses in loop statements) but had no concrete
> suggestions.  Now I too have warmed to the binding expression approach
> (partly because Guido has, so I'm preparing for the inevitable :^),
> mostly because of Tim's "humorous observation" about use in printf
> debugging.  The fact that there is this use case independent of block
> variable initialization (ie, in a loop or if statement) is quite
> attractive to me.
> 
> It's true, as I think Antoine pointed out, that it's easy enough to
> define a wrapper function that prints a value and returns it.

That wasn't me, but I agree with the idea anyway :-)

Regards

Antoine.




More information about the Python-Dev mailing list