Mega Code Archive

 
Categories / Python Tutorial / Buildin Function
 

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)