is this possible? I want to assign a value to a custom dictionary using <class_name>.<attribute_name> syntax.
here's an example:
class Foo:
def __init__(self):
self.__values__ = {}
def add_a_value_using_dot_syntax(self, index, value): # what should this be?
self.__values__[index] = value
bar = Foo()
bar.baz = 'hello'
print(bar.baz) # hello
print(bar.__values__) # {'baz': 'hello'}
I know that this can be done with bracket syntax by overriding __setitem__
but it doesn't seem to work for dot syntax..
Thanks