An example of calling vars() with a class instance : Vars : Buildin Function PYTHON TUTORIALS


PYTHON TUTORIALS » Buildin Function » Vars »

 

An example of calling vars() with a class instance


# Without arguments, return a dictionary corresponding to the current local symbol table. 
# With a module, class or class instance object as argument 
(or anything else that has a __dict__ attribute)
# returns a dictionary corresponding to the object's symbol table. 
# Reference from Python doc: http://docs.python.org/library/functions.html


class C(object):
     pass

c = C()
c.foo = 100
c.bar = 'Python'
print c.__dict__
print vars(c)



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Buildin Function
» Vars