22 Jun
2021
22 Jun
'21
11:12 a.m.
On Tue, Jun 22, 2021 at 8:01 PM Steven D'Aprano
The whole point of extension methods is that once the caller opts in to use them, method look ups (and that includes hasattr and getattr) must work as if the extension methods **are in place**.
The must be no semantic difference between:
obj.method(arg)
and
getattr(obj, 'method')(arg)
regardless of whether `method` is a regular method or an extension method.
And this is a problem. How is getattr defined? Is it counted as being in the current module? If it is, then has getattr magically become part of the module it's called from? Or do ALL lookups depend on where the function was called, rather than where it's defined? If 'method' is an extension method, where exactly is it visible? ChrisA