> Define a __repr__ or __str__ method for the class
Yes, then I could include the code John Machin suggested in there:
for attr, value in sorted(self.__dict__.iteritems()): blah
That will do nicely. Thanks all.
\d
--
http://mail.python.org/mailman/listinfo/python-list
"Donn Ingle" schrieb
> Is there a way to get a dump of the insides of an object?
> I thought pprint would do it.
>
print would actually like to do it if you told it how to do it.
print actually does it, but takes a default implementation if
you do not override __repr__ or __str__.
> If I had a cl
> AFAIK you have to roll your own. Here is a very rudimentary example:
Very cool, thanks.
\d
--
http://mail.python.org/mailman/listinfo/python-list
On Dec 8, 9:16 pm, Donn Ingle <[EMAIL PROTECTED]> wrote:
> Hi,
> Is there a way to get a dump of the insides of an object? I thought pprint
> would do it. If I had a class like this:
>
> class t:
> def __init__(self):
> self.x=1
> self.y=2
> self.obj = SomeOtherObj()
>
> Then it could displ
Hi,
Is there a way to get a dump of the insides of an object? I thought pprint
would do it. If I had a class like this:
class t:
def __init__(self):
self.x=1
self.y=2
self.obj = SomeOtherObj()
Then it could display it as:
t,
x,1,
y,2,
obj,
Or something like that -- a complete output