On Thu, May 10, 2018 at 3:32 AM, Terry Reedy <tjre...@udel.edu> wrote:
> 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. > I hope that's a typo (the can be no space between `:` and `=`, since `:=` is a single token, just like `<='). We *could* make this work while still ruling out the ambiguous cases (which involve top-level commas on either side of the assignment expression). OTOH I worry that this particular feature would cause `:=` to become part of many a teacher's bag of tricks to show off, exposing users to it way too early for any curriculum, and it might then elicit complaints that >>> def f(): ... a := 5 ... >>> f() >>> doesn't print `5`. So all in all I'm not sure I think this is important enough to support, and the rule "Use `:=` in expressions, not as a top level assignment" seems easier to explain and understand. -- --Guido van Rossum (python.org/~guido)
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/