Dictionary, iterate & update objects

Carl Banks pavlovevidence at gmail.com
Mon Dec 18 13:43:05 EST 2006


Dennis Lee Bieber wrote:
> On 16 Dec 2006 14:49:19 -0800, "jansenh" <henning.jansen at gmail.com>
> declaimed the following in comp.lang.python:
>
> > Yes.
> > [... the temp object is by ref, and any manipulation of the temp object
> > is to the object itself..? It really simplifies my first attempt]
> >
> 	For all practical purposes, everything in Python is "by ref" and the
> difference is whether the object itself is mutable (dictionaries, lists,
> class instances, modules) or immutable (strings, tuples, numbers). A
> mutable object is basically something that contains references to other
> objects

Not at all.  It's not even generally true of Python.  Mutability is
orthogonal to containership.

arrays, files, cStringIO objects, mmap objects, thread locks, some
iterator types, etc., are mutable but do not contain Python objects
(__dict__ excepted).

tuples, frozensets, instancemethods, are immutable but do contain
Python objects.


Carl Banks




More information about the Python-list mailing list