Is there a way to automatically print all the instance
data in a class? This is for debugging, I would like
to do something like dump(self) to snapshot the state
of the object.
Many TIA!
Mark
--
Mark Harrison
Pixar Animation Studios
--
http://mail.python.org/mailman/listinfo/python-list
Mark Harrison wrote:
Is there a way to automatically print all the instance
data in a class? This is for debugging, I would like
to do something like dump(self) to snapshot the state
of the object.
def dump(obj):
buf = ['%r %s :' % (obj, str(obj)]
for name in dir(obj):
attr =
Mark Harrison wrote:
Is there a way to automatically print all the instance
data in a class? This is for debugging, I would like
to do something like dump(self) to snapshot the state
of the object.
Would something like cPickle work? That allows you to dump objects into
files as they
Mark Harrison wrote:
Is there a way to automatically print all the instance
data in a class?
print self.__dict__
--
http://mail.python.org/mailman/listinfo/python-list
Some Googling yielded this recipe
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/137951/index_txt,
a little test shows promising results of the described recipe. BTW: the
Python Cookbook is always a good place to browse with questions other
people probably had as well!
--
Kamilche a écrit :
Mark Harrison wrote:
Is there a way to automatically print all the instance
data in a class?
print self.__dict__
Yeps - if you don't mind missing class attributes and data descriptors.
--
http://mail.python.org/mailman/listinfo/python-list