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. But that's not as flexible, and if you have more than one variable to "watch", you either need an argument to the wrapper to provide the variable's name, or different functions for different variables. _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com