Object Reference question

josef josefg at gmail.com
Thu Aug 27 19:04:38 CEST 2009


Thanks to everyone who responded.

I will be going with some sort of a = MyClass(name = 'a') format. It's
the Python way.

For me, it was very hard to accept that EVERYTHING is an object
reference. And that there are no object reference names, just string
entries in dictionaries. But I think it all makes sense now.

Thanks again,

Josef


On Aug 21, 1:07 am, josef <jos... at gmail.com> wrote:
> 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