osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] (name := expression) doesn't fit the narrative of PEP 20


On Thu, Apr 26, 2018 at 1:33 PM, Tim Peters <tim.peters at gmail.com> wrote:

>  And that *is* a thing that you will have to explain to newbies when they
> encounter
> > it for the first time.
>
> Sure.  That doesn't frighten me, though.  It's easy to explain what it
> does - although it may be hard to explain when it's _desirable_ to use
> it.
>

I'm with Raymond here -- though I'm not sure "newbies" is quite right --
I've found that newbies fall into two camps: folks to whom programming
comes naturally, and those that it doesn't (OK, it's a distribution, but a
bimodal one). And folks that are struggling with programming can struggle
even with simple assignment (name binding), particularly when you add even
function local scope. So having one more way to do assignment WILL make it
harder to teach, not because it's that hard, but because it's one more
thing to learn.

But the fact is that as Python has evolved (particularly with the jump to
py3) it has become less and less of a "scripting" language, and more of a
"systems" language. And also harder to learn. Anyone remember CP4E? Python
is not as good choice as a "newbie" language as it once was.

Adding := will move it a little bit more along the complexity path -- not
much, and that's where Python has gone anyway, so as Tim said, no one's
going to suffer either way this decision goes.

Hmm -- I wonder if a "pythonscript" will get forked off one day......

To judge from Stackoverflow volume, the single most misunderstood of
> all Python operators - by far - is "is" -


You now, I think instructors like me are partly responsible. "is" is rarely
useful outside of comparing to singletons. Yet I use it early in
instruction to do checks on name binding and show things with mutablilty,
etc.... which has the unfortunate side effect of making it seem like a more
common operator than it is.

I've even had students write code like:

if x is 3:

and thanks to interning, it appears to work!

-CHB


-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180427/e9de4a1a/attachment.html>