Adds a __getattr__ dunder to ValueHolder to enable getting attributes, and especially method calls, on contained objects.
This commit is contained in:
@ -142,10 +142,10 @@ class ValueHolder:
|
|||||||
return divmod(other, self._value)
|
return divmod(other, self._value)
|
||||||
|
|
||||||
def __pow__(self, other):
|
def __pow__(self, other):
|
||||||
return self._value**other
|
return self._value ** other
|
||||||
|
|
||||||
def __rpow__(self, other):
|
def __rpow__(self, other):
|
||||||
return other**self._value
|
return other ** self._value
|
||||||
|
|
||||||
def __ipow__(self, other):
|
def __ipow__(self, other):
|
||||||
self._value **= other
|
self._value **= other
|
||||||
@ -225,6 +225,9 @@ class ValueHolder:
|
|||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
self._value[key] = value
|
self._value[key] = value
|
||||||
|
|
||||||
|
def __getattr__(self, item):
|
||||||
|
return getattr(self._value, item)
|
||||||
|
|
||||||
|
|
||||||
def get_attribute_or_create(obj, attr, default):
|
def get_attribute_or_create(obj, attr, default):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user