Object Reference question

josef josefg at gmail.com
Fri Aug 21 02:07:18 EDT 2009


To begin, I'm new with python. I've read a few discussions about
object references and I think I understand them.

To be clear, Python uses a "Pass By Object Reference" model.
x = 1
x becomes the object reference, while an object is created with the
type 'int', value 1, and identifier (id(x)). Doing this with a class,
x = myclass(), does the same thing, but with more or less object
attributes. Every object has a type and an identifier (id()),
according to the Python Language Reference for 2.6.2 section 3.1.

x in both cases is the object reference. I would like to use the
object to refer to the object reference. If I have a gross
misunderstanding, please correct me.

The following is what I would like to do:
I have a list of class instances dk = [ a, b, c, d ], where a, b, c, d
is an object reference. Entering dk gives me the object: [MyClass0
instance at 0x0000, MyClass1 instance at 0x0008, MyClass2 instance at
0x0010 ... ]

I need the object reference name (a,b,c,d) from dk to use as input for
a file. Where do I find the memory location of the object reference
and the object reference name memory location? I am unconcerned with
the fact that the memory location will change the next time I run a
python session. I will be using the object reference name for
processing right away.

My main focus of this post is: "How do I find and use object reference
memory locations?"

Thoughts?
Thanks,

Josef



More information about the Python-list mailing list