0

Python 2.7

I'm using the below helper class, to access dictionary keys via property name. That is working fine. However it not showing nicely in the visual-studio-code debugger view. It is showing the repl() right next to the variable name, but I cannot "open" it to see all the key/values in the dict(), like I can do with normal dict(). Any idea how to achieve that? How is visual-studio-code determining what to show in the details when "opening" the variable?

class AttributeDict(dict):
    __getattr__ = dict.__getitem__
    __setattr__ = dict.__setitem__

    def __init__(self, *args, **kvargs):
        super(AttributeDict, self).__init__(*args, **kvargs)

Many thanks for your help

Juergen

Juergen
  • 699
  • 7
  • 20
  • I suspect that's part of the implementation of visual studio, they only offer that for known classes such as `dict` and once you've used some other class, they don't bother "looking inside". Just a guess though – Ofer Sadan May 31 '18 at 07:16
  • That's exactly the reason why I subclassed from `dict` – Juergen May 31 '18 at 08:23
  • 1
    The problem is that if you subclass there's no guarantee that you won't have unbounded behaviour, making it a possibility that "opening" the object in the debugger will crash your system, so the debugger probably has to be conservative. – Brett Cannon May 31 '18 at 19:30

0 Answers0