AttrDict icon indicating copy to clipboard operation
AttrDict copied to clipboard

Override __dir__ to allow for tab completion in ipython and easier inspection

Open aldanor opened this issue 9 years ago • 3 comments

The common thing to do if you override __getattr__ is to also override __dir__ like so:

def __dir__(self):
    # you may also want to filter the keys to only include the strings
    return sorted(set(super(AttrDict, self).__dir__()) + set(self.keys()))

This would make it much easier to use attrdict in IPython and other IDEs as you would gain auto-completion.

aldanor avatar Aug 31 '15 09:08 aldanor

Is this repository abandoned?

aldanor avatar Nov 09 '15 15:11 aldanor

@aldanor Perhaps the @bcj will include this more quickly if you submit a pull request?

erikcw avatar Dec 23 '15 23:12 erikcw

+1

nowox avatar Nov 10 '16 08:11 nowox