Created
July 26, 2017 19:18
-
-
Save Imperat/d4e2257e47d9086dcb14bb72b514bc98 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def decorator(func): | |
| def result(*args, **kwargs): | |
| print ('log function!', func) | |
| return func(*args, **kwargs) | |
| return result | |
| def regenerate(d): | |
| new_d = {} | |
| for i, j in d.items(): | |
| if hasattr(j, '__call__'): | |
| new_d[i] = decorator(j) | |
| else: | |
| new_d[i] = j | |
| return new_d | |
| class MetaMarmon(type): | |
| def __new__(self, name, bases, namespace): | |
| instance = super(MetaMarmon, self).__new__( | |
| self, name, bases, regenerate(namespace)) | |
| instance.hel = 'Rasim' | |
| return instance | |
| class Marmon(metaclass=MetaMarmon): | |
| def marmon(self): | |
| print ('kefal') | |
| import pdb; pdb.set_trace() | |
| print (type(Marmon)) | |
| print (type(Marmon())) | |
| print (type(MetaMarmon)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment