diff options
Diffstat (limited to 'Demo')
-rw-r--r-- | Demo/newmetaclasses/Eiffel.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Demo/newmetaclasses/Eiffel.py b/Demo/newmetaclasses/Eiffel.py index 3e68611..1dd7e6c 100644 --- a/Demo/newmetaclasses/Eiffel.py +++ b/Demo/newmetaclasses/Eiffel.py @@ -4,6 +4,11 @@ from new import function class EiffelBaseMetaClass(type): + def __new__(meta, name, bases, dict): + meta.convert_methods(dict) + return super(EiffelBaseMetaClass, meta).__new__(meta, name, bases, + dict) + def convert_methods(cls, dict): """Replace functions in dict with EiffelMethod wrappers. @@ -30,10 +35,6 @@ class EiffelBaseMetaClass(type): class EiffelMetaClass1(EiffelBaseMetaClass): # an implementation of the "eiffel" meta class that uses nested functions - def __new__(meta, name, bases, dict): - meta.convert_methods(dict) - return super(EiffelMetaClass1, meta).__new__(meta, name, bases, dict) - def make_eiffel_method(func, pre, post): def method(self, *args, **kwargs): if pre: @@ -80,7 +81,7 @@ class EiffelDescriptor(object): self._post(inst, x, *args, **kwargs) return x -class EiffelMetaClass2(EiffelMetaClass1): +class EiffelMetaClass2(EiffelBaseMetaClass): # an implementation of the "eiffel" meta class that uses descriptors make_eiffel_method = EiffelDescriptor |