On Oct 29, 12:46 pm, "Martin Marcher" <[EMAIL PROTECTED]> wrote: > 2007/10/29, Hrvoje Niksic <[EMAIL PROTECTED]>: > > > Sbe unpx inyhr, urer vf n cbffvoyr vzcyrzragngvba: > > ... > > was that on purpose? > > martin > > --http://noneisyours.marcher.namehttp://feeds.feedburner.com/NoneIsYours
for humans: For hack value, here is a possible implementation: import inspect def _find(frame, obj): for name, value in frame.f_locals.iteritems(): if value is obj: return name for name, value in frame.f_globals.iteritems(): if value is obj: return name raise KeyError("Object not found in frame globals or locals") class X: def debug(self): print ("Caller stores me in %s (among other possible places)" % _find(inspect.currentframe(1), self)) >>> xyzzy = X() >>> xyzzy.debug() Caller stores me in xyzzy (among other possible places) >>> a = b = X() >>> a.debug() Caller stores me in a (among other possible places) >>> b.debug() Caller stores me in a (among other possible places) >>> X().debug() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 4, in debug File "<stdin>", line 8, in _find KeyError: 'Object not found in frame globals or locals' -- http://mail.python.org/mailman/listinfo/python-list