Finding the instance reference of an object

Aaron "Castironpi" Brady castironpi at
Thu Oct 16 20:51:43 CEST 2008

On Oct 16, 12:25 pm, Astley Le Jasper <Astley.lejas... at>
> Thanks for all the responses. That helps.
> Ta

If you're sure it's unique, why not just scan through the pairs in

for k, v in locals():
  if v is the_object_im_looking_for:
    name_im_looking_for= k

This method can sometimes return more than one name, due to the
variable ordering of objects in dictionaries.

More information about the Python-list mailing list