This is probably obvious to you Python Geniuses (tm) out there but,
it is very late and I am experiencing Brain Fade:
Given the ID of an object, is there a way to access it? For example,
if we have the ID of a class instance, is there a way to invoke its
methods and attributes knowning only that
Tim Daneliuk wrote:
This is probably obvious to you Python Geniuses (tm) out there but,
it is very late and I am experiencing Brain Fade:
Given the ID of an object, is there a way to access it?
short answer: no.
longer answer: write a small C extension that casts an integer (or long
longer answer: write a small C extension that casts an integer (or long
integer)
argument to a PyObject, increments the refcount, and returns the object.
here's a pointer to a pointer to such a function, btw:
http://mail.python.org/pipermail/python-list/1999-October/013715.html
(see
Diez B. Roggisch wrote:
Given the ID of an object, is there a way to access it? For example,
if we have the ID of a class instance, is there a way to invoke its
methods and attributes knowning only that ID? Similarly, if we have the
ID of a function, is there a way to call it?
No.
This comes
Tim Daneliuk [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Given the ID of an object, is there a way to access it?
You got the right short answer already.
Another long answer 'yes' is to keep a dictionary mapping ids to objects,
but as Diez pointed out, you need a real reason to do