Thu, 11 Jan 2001 13:54:13 -0500
On Thu, Jan 11, 2001 at 01:19:56PM -0500, Michael P. Reilly wrote:
| > Dear Sir/Madam,
| > Does python offer any method or function to return the name of any object?
| > eg.
| > >>>aaa=None
| > >>>print Wanted_Function(aaa)
| > 'aaa'
| > the question is if such a function like Wanted_Function() actually exists.
| > Many Thanks,
| > Xia XQ
| Not easily, no. As D-Man was referring to, Python is not a variable-
| based language, but a name-binding one (that is why there is no pointer
On the other hand, some objects do have a __name__ attribute, but not
variables. Those objects include modules, functions and classes.
>>> import os
>>> foo = os
Not quite what you were looking for, right?