On Mon, Mar 26, 2018 at 03:33:52PM +0100, Rhodri James wrote:
> While my crystal ball is cloudy, I can well imagine beginners becoming
> very confused over which symbol to use in which circumstance, and a lot
> of swearing when:
>
> x := f()
> if (y = g(x)) is not None:
> h(y)
>
> results in syntax errors.
I remember as a beginner being terribly confused when writing dicts and
constantly writing {key=value}. It is part of the learning process, and
while we shouldn't intentionally make things harder for beginners just
for the sake of making it harder, we shouldn't necessarily give them
veto over new features :-)
(I must admit that even now, if I'm tired and distracted I occasionally
make this same mistake.)
But we also have the opportunity to make things easier for them. I
presume that the syntax error could diagnose the error and tell them
how to fix it:
SyntaxError: cannot use := in a stand-alone statement, use =
SyntaxError: cannot use = in an assignment expression, use :=
or similar. Problem solved.
--
Steve
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/