Label-Value (was: Re: Inheriting the @ sign from Ruby)

Remco Gerlich scarblac at pino.selwerd.nl
Tue Dec 12 12:45:45 EST 2000


Roy Katz <katz at Glue.umd.edu> wrote in comp.lang.python:
> On Tue, 12 Dec 2000, Fredrik Lundh wrote:
> 
> > The real problem is that many Python tutorials fail to explain
> > how things work (or hide it somewhere in the exercises), but
> > that's not really Guido's fault...
> 
> Tough for the new Python programmer, then.  It's nt fair to them. 
> 
> > (Hint: Everything is a reference to an object.  Variables are
> > named references, not actual objects.  Some objects can be
> > modified in place.  Some cannot be modified.  That's all)
> 
> Okay! tell me, which are the objects which cannot be modified in place?

Integers, longs, complex numbers, strings, functions, tuples, types, floats
and None are immutable. Most of these are obvious; the number 3 is the
number 3, why would you change that?!

Lists, classes, instances, dictionaries and modules are mutable.

Did I miss any?

So there are only three mutable things: lists, dictionaries, and namespaces.

Anyway, the important ones of these are in any Python book. You sure you've
been programming Python for three years?

> assume these are int's, long's, float's, etc.  Strings, lists, objects and
> dictionaries are call-by-reference.  Pardon my choice of diction, but I am
> against inventing new terminiologies (modified-in-place??).

Mutable and immutable. And *everything* is by reference, including
assignment. No new terminology here.

> I want to know where this is documented.  Specifically, where is the
> dichotomy of ints/longs/floats vs. objects/strings/lists/dictionaries.

Strings are not mutable.

There is no real dichotomy here. Some types have methods that can change
the type, other types don't. Some types are namespaces (modules, classes
and instances), and they can be changed.

> While I'm brainstorming with Python grammar changes,

Not a very useful idea 10 years after the language was released, but
whatever... 

-- 
Remco Gerlich



More information about the Python-list mailing list