python - Programmatic way to list object properties and their values? -
i'm relatively new python still, sense free allow me know if there's basic i'm missing.
in involvement of easy debugging, i've gotten in habit of creating show() procedure every object create. example:
class yourmom: def __init__(self): self.name = "" self.age = "" self.children = [] #end init() def show(self): print "name '%s'" % (self.name) print "age '%s'" % (self.age) in self.children: print " children: '%s'" % (i) #end show() #end yourmom class
so question simple: there programmatic way show() procedure without needing write manually each time?
edit: there similar question here: list attributes of object i'm looking values in object properties list of them.
yes, it's python builtin function called vars
.
python object
No comments:
Post a Comment