This vars()
function returns the mapping of an object’s (writable) attributes.
issubclass([object])
Here,
__dict__()
special attribute.Note: Objects such as modules and instances have an updateable __dict__
attribute; however, other objects may have write restrictions on their __dict__
attributes (for example, new-style classes use a dictproxy to prevent direct dictionary updates).
Without an argument, vars()
acts like locals()
. Note, that the local dictionary is only useful for reading since updates to the local dictionary are ignored.
>>> class Class1:
... a = 13
... b = 7
...
>>> vars(Class1)
mappingproxy({'__module__': '__main__', 'a': 13, 'b': 7, '__dict__': <attribute '__dict__' of 'Class1' objects>, '__weakref__': <attribute '__weakref__' of 'Class1' objects>, '__doc__': None})