I want to see class attributes for a subclass of str
in the debugger.
Refer to the picture - I want to have the dropdown arrow next to a
(which is a POSString
object). In other words, in the Pycharm debugger I want to have the option to doubleclick a
and see the attribute bar
with value "HELLO"
, exactly like for the foo
object.
Is this possible in PyCharm, and if yes how?
The two classes:
class Foo:
bar = "HELLO"
class POSString(str):
bar = "HELLO"
def __init__(self, pos="", *args, **kwargs):
super().__init__(*args, **kwargs)
self.pos = pos
def __hash__(self):
return hash((str(self), self.pos))
def __eq__(self, other):
return super().__eq__(other) and self.pos == other.pos
And how I create my two objects:
foo = Foo()
a = POSString("banana")
I am using Python 3.7.1.
PyCharm:
PyCharm 2018.2.5 (Professional Edition)
Build #PY-182.5107.22, built on November 13, 2018
JRE: 1.8.0_152-release-1248-b22 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.15.0-43-generic
from Showing class attributes in the PyCharm debugger when subclassing str
No comments:
Post a Comment