easy way to dump a class instance?

2006-05-05 Thread Mark Harrison
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

Re: easy way to dump a class instance?

2006-05-05 Thread bruno at modulix
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 =

Re: easy way to dump a class instance?

2006-05-05 Thread Carl J. Van Arsdall
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

Re: easy way to dump a class instance?

2006-05-05 Thread Kamilche
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

Re: easy way to dump a class instance?

2006-05-05 Thread [EMAIL PROTECTED]
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! --

Re: easy way to dump a class instance?

2006-05-05 Thread Bruno Desthuilliers
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