
3 Dec
2019
3 Dec
'19
10:36 a.m.
What if there was a general mechanism to allow operators to be implemented by user code that does not belong to the class?
If the name [e.g.] __operatorhook_or__ is defined anywhere in a module, within that module all calls to that operator are replaced with a two-step process:
* within that module *
So this would not happen in other modules when that module was imported...? But would this mean that if I wanted the operation be effective for all modules, I would either have to define it in every module I have written, or import the function by name? E.g.:
# mod1 def __operatorhook_or__(obj1, obj2): ...
# mod2 from mod1 import __operatorhook_or__