Lies in education [was Re: The "loop and a half"]

Steve D'Aprano steve+python at pearwood.info
Fri Oct 13 10:39:33 EDT 2017


On Fri, 13 Oct 2017 11:54 pm, Gregory Ewing wrote:

> Neil Cerutti wrote:
>> I can tell at a glance if a parameter is expected to be
>> modifiable just by looking at the function signature.
> 
> The question is why doesn't anyone feel the need to be
> able to do that for Python functions? Whether a function
> modifies things passed to it is just as important to
> know in Python as it is in C.

Lots of people would like Python to have a "freeze" function that can make
immutable objects, it is a moderately common feature request.

Some people (myself included) would like a "const" declaration that gives us
names that can only be bound to once:

const spam = "NOBODY expects the Spanish Inquisition!!!"  # Okay
spam = "foo"  # Error.


I don't mind if that is a runtime error, although a compile time error would
be nicer.

I don't know if either of these (actual immutable pure-Python objects, and
un-rebindable names) count as quite the same thing you are asking Neil about.
But I trust they're related.


-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list