Skip to content

Instantly share code, notes, and snippets.

@Imperat
Created July 26, 2017 19:18
Show Gist options
  • Select an option

  • Save Imperat/d4e2257e47d9086dcb14bb72b514bc98 to your computer and use it in GitHub Desktop.

Select an option

Save Imperat/d4e2257e47d9086dcb14bb72b514bc98 to your computer and use it in GitHub Desktop.
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