How to retrieve a variable's name in python at runtime?

后端 未结 8 1482
悲哀的现实
悲哀的现实 2020-11-28 13:33

Is there a way to know, during run-time, a variable\'s name (from the code)? Or do variable\'s names forgotten during compilation (byte-code or not)?

e.g.:



        
8条回答
  •  爱一瞬间的悲伤
    2020-11-28 13:40

    Just yesterday I saw a blog post with working code that does just this. Here's the link:

    http://pyside.blogspot.com/2009/05/finding-objects-names.html

提交回复
热议问题