News for hackers. Stuff that matters.
Re:The PEPs of Python 3.9 by pbowyer on Thursday May 28, 2020 @05:04PM (#23342599)
> And honestly, I would be rich if I got a dollar every time a student does this:

> msg.upper()

> Instead of:

> msg = msg.upper()

> And then call me to say it doesn't work.

On this, isn't the student's reasoning sensible? E.g. "If msg is a String object that represents my string, then calling .upper() on it will change (mutate) the value, because I'm calling it on itself"?

If the syntax was upper(msg) or to a lesser extent String.upper(msg) then the new-to-programming me would have understood more clearly that msg was not going to change. Have you any insights into what your students are thinking?

Re:The PEPs of Python 3.9 by pansa2 on Thursday May 28, 2020 @07:12PM (#23344188)
> String.upper(msg)

That was the original syntax [0], before the string functions became methods. I agree that a method more strongly implies mutation than a function does.

Also, for consistency with list methods like `reverse` (which acts in place) and `reversed` (which makes a copy), shouldn’t the method be called `uppered`?!

[0] https://docs.python.org/2/library/string.html#deprecated-str...

Re:The PEPs of Python 3.9 by moonchild on Thursday May 28, 2020 @07:58PM (#23344617)
'uppercased'
Re:The PEPs of Python 3.9 by pansa2 on Friday May 29, 2020 @02:06AM (#23346729)
Ah, of course.

Also, it looks like that’s the name that Swift uses.

Re:The PEPs of Python 3.9 by BiteCode_dev on Thursday May 28, 2020 @06:26PM (#23343624)
A student don't know anything about mutability, and since Python signatures are not explicit, there is no way to know they have to do that.

It's just something to be told. A design decision, like there are thousands to learn in IT, that you just can't guess.