-
-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Labels
enhancementNew feature or requestNew feature or request
Description
The following subclassing worked in VScode notebook . Is it possible to enhance benedict to just do this built-in to support tab completion?
Maybe some keys would have to be converted to replace spaces with underscores etc (not done below)
Also if any subdicts could also be converted automatically to benedict so tab completion can work on nested dictionaries.
from benedict import Benedict
class AutoCompleteBenedict(Benedict):
def __dir__(self):
# grab the normal attributes…
attrs = super().__dir__()
try:
# …and add your dynamic keys
attrs.extend(self.keys())
except Exception:
pass
return list(dict.fromkeys(attrs)) # dedupe, preserve order
# usage
mydict = AutoCompleteBenedict({'foo': 1, 'bar': 2})
# now in IPython / VSCode REPL, typing “mydict.<TAB>” will show foo, bar, etc.
fabiocaccamo
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Projects
Status
Todo