The issue was more of a wrapping around numpy array. Found the solution
already. Unfortunately, there is no equivalent to __getattr__, the only way is
to dynamically define them from meta. It seems it’s pretty standard to just
have a collection of special method names and using them for similar
Il giorno mercoledì 26 luglio 2023 alle 20:35:53 UTC+2 Dom Grigonis ha scritto:
> Tried exactly that and didn’t work. Neither __getattr__, nor __getattribute__
> of meta is being invoked.
> > On 26 Jul 2023, at 10:01, Chris Angelico via Python-list
> > wrote:
> >
> > On Wed, 26 Jul 2023 at 16:
Tried exactly that and didn’t work. Neither __getattr__, nor __getattribute__
of meta is being invoked.
> On 26 Jul 2023, at 10:01, Chris Angelico via Python-list
> wrote:
>
> On Wed, 26 Jul 2023 at 16:52, Dom Grigonis wrote:
>>
>> Could you give an example? Something isn’t working for me.
>
Dom Grigonis wrote at 2023-7-26 05:22 +0300:
> ...
>Is there a way to achieve it without actually implementing operators?
>I have looked at Proxy objects, but they do not seem suited to achieve this.
Proxying is a good approach:
you might have a look at `dm.reuse.proxy.OverridingProxy` (--> `dm.re
On Wed, 26 Jul 2023 at 16:52, Dom Grigonis wrote:
>
> Could you give an example? Something isn’t working for me.
>
This is a metaclass:
class Meta(type):
...
class Demo(metaclass=Meta):
...
In order to catch those kinds of attribute lookups, you'll need the
metaclass to hook them. And y
Could you give an example? Something isn’t working for me.
> On 26 Jul 2023, at 09:40, Chris Angelico via Python-list
> wrote:
>
> On Wed, 26 Jul 2023 at 12:23, Dom Grigonis via Python-list
> wrote:
>> print(a + 1)# TypeError: unsupported operand type(s) for +: 'A'
>> and 'int'
>>
On Wed, 26 Jul 2023 at 12:23, Dom Grigonis via Python-list
wrote:
> print(a + 1)# TypeError: unsupported operand type(s) for +: 'A'
> and 'int'
>
> Is there a way to achieve it without actually implementing operators?
> I have looked at Proxy objects, but they do not seem suited to ac
To illustrate what I was trying to achieve:
class A:
def __init__(self, arr):
self.arr = arr
def __getattr__(self, name):
arr_method = getattr(self.arr, name)
def wrapper(*args, **kwargs):
new_arr = arr_method(*args, **kwargs)
return type(se