Skip to content
This repository was archived by the owner on Feb 2, 2019. It is now read-only.

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

@aldanor

Description

@aldanor

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions