On Mon, Jun 21, 2021 at 02:54:52PM -0300, Soni L. wrote:
Quite the opposite. You ask the local module (the one that the code was compiled in), and the module decides whether/when to ask the object itself.
In other words, every
foo.bar
would be sugar for
__getattr__(foo, "bar")
(where __getattr__ defaults to builtins.getattr) instead of being sugar for
<builtins.getattr>(foo, "bar")
All you've done here is push the problem further along -- how does `__getattr__` (`__getattribute__`?) decide what to do? * Why is this extension-aware version per module, instead of a builtin? * Does that mean the caller has to write it in every module they want to make use of extensions? * Why do we need a second attribute lookup mechanism instead of having the existing mechanism do the work? * And most problematic, if we have an extension method on a type, the builtin getattr ought to pick it up. By the way, per-module `__getattr__` already has a meaning, so this name won't fly. https://www.python.org/dev/peps/pep-0562/ -- Steve