Gabriel Genellina wrote: > En Sat, 19 May 2007 20:42:53 -0300, Paul McGuire <[EMAIL PROTECTED]> > escribió: > >>>>> z = id(results) >>>>> for x in globals().values(): >> ... if id(x)==z: break >> ... >> >> This gives me a variable x that is indeed another ref to the results >> variable: >>>>> x is results >> True >>>>> x.x >> 123 >> >> Now is there anything better than this search technique to get back a >> variable, given its id? > > py> class A:pass > ... > py> class B:pass > ... > py> a=A() > py> id(a) > 10781400 > py> del a > py> b=B() > py> id(b) > 10781400 > > Now if you look for id=10781400 you'll find b, which is another, > absolutely unrelated, object.
That's not what I get: Python 2.5 (r25:51908, Mar 13 2007, 08:13:14) [GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin Type "help", "copyright", "credits" or "license" for more information. >>> class A: pass ... >>> class B: pass ... >>> a = A() >>> id(a) 2146651820 >>> b = B() >>> id(b) 2146651948 -- Michael Hoffman -- http://mail.python.org/mailman/listinfo/python-list