classes and dictionaries

Jason Swails jason.swails at
Thu Sep 16 02:13:04 CEST 2010

Hello everyone,

I'm encountering an issue in one of my Python classes that makes extensive
use of dictionaries.  I was under the impression that each time an object
was instantiated, all of its variables were created in a new section of
memory, so that if you change the value of the variable in one instance, it
left that variable's value in another instance alone.  In the object that I
wrote, I have 3 different dictionaries: parm_data, pointers, and formats,
all defined in the same place.  When I load 2 instances of this object,
parm_data and formats each take on different values between the two objects
(as they should), but for some reason pointers does not.  I've seen this
problem with python2.6.4 and 2.6.1 (and I believe earlier versions as well,
but I'm not sure).  I've attached a tarball with the relevant code and a
sample script that shows what I mean.

If anyone can tell me why the dictionary from 2 different objects are
exactly the same for pointers, but are different for, e.g. parm_data and
formats, that would be greatly appreciated.


Jason M. Swails
Quantum Theory Project,
University of Florida
Ph.D. Graduate Student
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: prmtop_test.tgz
Type: application/x-gzip
Size: 10749 bytes
Desc: not available
URL: <>

More information about the Python-list mailing list