*Utility class to interact with a dictionary as if it were an object. AD is an alias to this class
FEATURES: 0. Access and modify keys (including nested keys) as if they were object attributes, supporting tab-completion. Example: self.key1.key2[0].key3 1. Keys and values are recursively converted to AttrDict instances. 2. Pretty-print the dictionary using print. 3. Convert the entire structure to a regular dictionary at any time using self.to_dict() / self.dict(). 3. Recursively remove keys using self.drop(key) from a JSON object. 4. Apply a function to all values at all levels using map.
GOTCHAS: 1. All integer keys are implicitly converted to strings due to the enforced self.key format. 2. You can still use self[int], but this internally converts the integer to a string.
METHODS: - items(): Return the items of the AttrDict as key-value pairs. - keys(): Return the keys of the AttrDict. - values(): Return the values of the AttrDict. - update(dict): Update the AttrDict with key-value pairs from another dictionary. - get(key, default=None): Get the value associated with a key, with an optional default value. - __iter__(): Allow iteration over the keys of the AttrDict. - __len__(): Return the number of keys in the AttrDict. - __repr__(): Return a string representation of the AttrDict. - __dir__(): List the keys of the AttrDict as attributes. - __contains__(key): Check if a key exists in the AttrDict, use ‘a.b.c’ notation to directly check for a nested attribute. - __delitem__(key): Delete a key from the AttrDict. - map(func): Apply a function to all values in the AttrDict. - drop(key): Recursively remove a key and its values from the AttrDict. - to_dict(): Convert the AttrDict and its nested structure to a regular dictionary. - pretty(print_with_logger=False, *args, **kwargs): Pretty-print the AttrDict as JSON. - __eq__(other): Compare the AttrDict with another dictionary for equality. - find_address(key, current_path=""): Find and return all addresses (paths) of a given key in the AttrDict. - summary(current_path='', summary_str='', depth=0, sep=' '): Generate a summary of the structure and values in the AttrDict. - write_summary(to, **kwargs): Write the summary to a file or stream. - fetch(addr): Retrieve a value at a specified address (path).
PARAMETERS: - data (dict, optional): Initial data to populate the AttrDict.
USAGE: - Create an AttrDict instance by providing an optional initial dictionary, and then access and manipulate its contents as if they were object attributes.