Debugger Variable View in Locals

Sep 5, 2012 at 9:36 AM

Hello,

While Debugger using the Python Debugger, I often have to see which values are inside my class instances.

In the Locals view I can see the name of an instance variable, the value and the type

But the value for the instance variable if always 

<__main__,MyClass instance at 000000013245679 >

How can I change this, to see something else ?

in C# I have to override the ToString() method.

Can I do the same thing in Python ?

Coordinator
Sep 5, 2012 at 4:10 PM

In Python you can override the __str__ and __repr__ methods for this. This question on Stack Overflow covers it pretty well: http://stackoverflow.com/questions/1436703/difference-between-str-and-repr-in-python