<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote"><span class=""></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div>I did a little more digging, and turned up the __self__ and __func__ attributes of bound methods:</div><div><a href="https://stackoverflow.com/questions/4679592/how-to-find-instance-of-a-bound-method-in-python" target="_blank">https://stackoverflow.com/<wbr>questions/4679592/how-to-find-<wbr>instance-of-a-bound-method-in-<wbr>python</a><br></div><div><br></div><div>So we might need another decorator function, but it seems that the current interface would actually suffice just fine for overriding methods. I'll update the NEP with some examples. It will look something like:</div><div><br></div><div>def __array_function__(self, func, types, args, kwargs):</div><div>  ...</div><div>  if isinstance(func, types.MethodType):</div><div>    object = func.__self__</div><div>    unbound_func = func.__func__</div><div>    ...</div><div><br></div></div></div></div></blockquote><div><br>For C classes like the ufuncs, it seems `__self__` is defined for methods as well (at least, `np.add.reduce.__self__` gives `np.add`), but not a `__func__`. There is a `__name__` (="reduce"), though, which means that I think one can still retrieve what is needed (obviously, this also means `__array_ufunc__` could have been simpler...)<br></div><div><br></div><div>-- Marten<br></div></div></div></div>