Accessing Objects Based On Their ID

2005-02-15 Thread Tim Daneliuk
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

Re: Accessing Objects Based On Their ID

2005-02-15 Thread Fredrik Lundh
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

Re: Accessing Objects Based On Their ID

2005-02-15 Thread Fredrik Lundh
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

Re: Accessing Objects Based On Their ID

2005-02-15 Thread Tim Daneliuk
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

Re: Accessing Objects Based On Their ID

2005-02-15 Thread Terry Reedy
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