pyhacks
pyhacks
In order to solve problems of ```hasattr(obj, "__iter__")``` and ```callable(obj)``` you can define a function generating a ObjectProxy and before instantiating it, modify it depending on the needs of ```obj```....
You can't do that inside ```__init__``` because magic methods aren't automatically called when they are object attributes instead of class attributes. See this code: ```python class A: def __init__(self): def...
We can handle the case of assigning to ```__wrapped__``` in ```__setattr__``` so that class structure will adapt to the new object: ```python class A: def __init__(self, wrapped): self.__wrapped__ = wrapped...
@GrahamDumpleton I just found [this](https://github.com/GrahamDumpleton/wrapt/issues/73) issue from 2016 and it's still not fixed. If you are busy with other things these days, I can also update the python part of...
I modified my previous code snippet to check whether we are working with a dynamically added ```__call__``` attribute or not before deleting it. This will not delete the ```__call__``` attribute...
Great news you already implemented many dunder methods. But just like you gave the example of ```__matmul__```, there are still many other unimplemented dunder methods. Example: ```__get__```, ```__set__```, ```__delete__```
In your sentence: > + ```proxy.attr``` → Python calls ```proxy.__get__(obj, type(obj))``` → calls ```wrapped.__get__(obj, type(obj))``` I think you made a typo by writing ```proxy.attr``` instead of ```obj.attr```, or even better,...
Having an object proxy wrapping a data descriptor would be as easy as having an object proxy wrapping a non data descriptor. Just add ```__set__``` and ```__delete__``` dynamically in ```__new__```...
Great! Now ObjectProxy supports most important dunder methods. What about these methods: ```__init_subclass__```, ```__set_name__```, ```__class_getitem__```, ```__length_hint__```, ```__trunc__```, ```__floor__```, ```__ceil__```, ```__buffer__```, ```__release_buffer__``` And btw, when will you upload your last changes...
> adding more and more methods that way gives me concern Since now we have a seperate class called ```AutoObjectProxy``` you can support ```__length_hint__``` in it and not in the...