
Le 10/05/2018 à 09:32, Terry Reedy a écrit :
On 5/9/2018 11:33 PM, Guido van Rossum wrote:
I now think that the best way out is to rule `:=` in the top level expression of an expression statement completely
I would like to be able to interactively enter
a: = f(2,4)
to have 'a' echoed as well as bound.
This behaviour is reachable by using: print(a := f(2,4)) Otherwise, I can see coming a new wave of devs saying assignment with "=" is outdated, and we should use the new assignment operator ":=". Cleaning code by removing useless prints is something, having to go through the syntax to remove the ":" of some ":=", and having to test everything again to be sure we didn't break anything is another matter (long live unit tests! But still...). Side note: I wouldn't recommand to use `print(a := f(2,4))` either, as it would be a print-with-a-side-effect. Which would then also break the code if removed the usual way by deleting the line (or commenting it if you like messy). Maybe, for another proposal of course, we could allow the shell to be more verbose, by printing any explicit assignment (whether we used "=" or ":=" wouldn't matter)? -Brice