So, I realized this after a lot of experimentation.
Basically in the metaclass' __new__ you can iterate through each method in the class namespace and replace each method in the class created with the new version, which starts before the logic, the function itself and the logic after.Here is a sample:
class TestMeta(type): def __new__(mcl, name, bases, nmspc): def replaced_fnc(fn): def new_test(*args, **kwargs):
Note that if you use this code the way it will trigger the pre / post operation for init and other built-in functions.
source share