[Tutor] introspection
Alex Kleider
akleider at sonic.net
Mon Apr 20 17:24:42 CEST 2015
Does python provide the introspective ability to retrieve the name to
which an object is bound?
For example:
$ python3
Python 3.4.0 (default, Apr 11 2014, 13:05:18)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 69
>>> print("Identifier <{}> is bound to {}.".format(a.__name__, a))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'int' object has no attribute '__name__'
More information about the Tutor
mailing list