3

As far as I remember, in IntelliJ, the debug window has the option to view the toString() of an object instead of its memory address. Is there a way to do this in PyCharm with an object's __str__(self)?

enter image description here

enter image description here

0

2 Answers 2

3

This should be done with __repr__:

class Foo:
    def __repr__(self):
        return 'foo object'

f = Foo()
pass # breakpoint here

This shows 'foo object' in the debugger's variables window.

Sign up to request clarification or add additional context in comments.

Comments

2

Pycharm in variable view / debugging is showing __str__ object representation instead of __repr__.

Here was created a work-item on JetBrains website. Unforunetally I think there is still no progress.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.