I have a class for which I defined __getattr__
to pull attribute data from a YAML file dynamically. It looks something like this:
class Example:
def __init__(self, yaml_path):
self.rand = 0
with open(yaml_path) as file:
self._data = yaml.load(file, Loader=yaml.FullLoader)
def __getattr__(self, name):
return self._data[name]
The class works as expected, but the autocomplete abilities in Jupyter are now lost for the instance of this class. Not only does the autocomplete not work on the dynamic attributes but also the standard attributes defined in the constructor are not available.
How can I achieve the same result while keeping the autocompletion?