Issue
I create my dictionary through the following class, that at the end I believe is an ordinary dictionary subclass.
class my_dictionary(dict):
# Function to add key:value
def add(self, key, value):
self[key] = value
I use this dictionary subclass to associate a list to a string:
from collections import OrderedDict
timeDict = my_dictionary()
filename = 'name'
t = [0, 1, 2]
timeDict.add(filename, t)
The code creates the dictionary and uses it as expected:
However, I can not inspect the dictionary in Spyder by clicking on it in variable explorer! I get the following error dialog:
Error
Spyder was unable to retrieve the value of this variable from the console.
The error message was:
AttributeError("Can't get attribute 'my_dictionary' on ",)
Solution
This is a known issue in spyder: #8856. The fix for it is under development for Spyder 4.0, according to the developers.
In the meantime, your particular use-case has a workaround. The add
method does not add any new functionality, so you can use a plain dict
. The statement timeDict.add(filename, t)
can be replaced by timeDict[filename] = t
if you choose to do that.
If your goal is to experiment with overriding built it classes, you will not be able to use Spyder's variable explorer for now.
Answered By - Mad Physicist
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.