functions, list, default parameters

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Tue Nov 2 08:12:49 CET 2010

In message <mailman.475.1288670833.2218.python-list at>, Robert Kern 

> On 2010-11-01 22:31 , Lawrence D'Oliveiro wrote:
>> In message<8j1seqFa1eU2 at>, Gregory Ewing wrote:
>>> Steven D'Aprano wrote:
>>>> And how does Python know whether some arbitrary default object is
>>>> mutable or not?
>>> It doesn't, that's the whole point.
>> Of course it knows. It is the one defining the concept in the first
>> place, after all.
> No, the Python interpreter doesn't define the concept. The Python language
> developers did.

The Python language developers said “let there be light”, and the Python 
interpreter gave forth light. So which one defines the concept of “light”?

> "Immutable objects" are just those without an obvious API for modifying
> them.

They are ones with NO legal language constructs for modifying them. Hint: if 
a selector of some part of such an object were to occur on the LHS of an 
assignment, and that would raise an error, then the object is immutable. The 
interpreter already knows all this.

> With various trickeries, I can mutate any immutable object.

None within the Python language itself. Which is what we’re talking about 
here: a language construct which is probably one of the top 3 sources of 
grief to Python newbies. And not-so-newbies.

More information about the Python-list mailing list