Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from types import FunctionType
- def log(func):
- def function(*args,**kwargs):
- with open("logfile","a") as f:
- f.writelines(func.__name__ + str(args) + " " + str(kwargs) + str(func(*args,**kwargs)) + "\n")
- return function
- class loggermetaclass(type):
- def __new__(meta, classname,supers, classdict):
- for attr, attrval in classdict.items():
- if type(attrval) is FunctionType and attr[0] != "_" and attr[1] != "_":
- classdict[attr] = log(attrval)
- return type.__new__(meta,classname,supers,classdict)
- class logger():
- __metaclass__ = loggermetaclass
- def printint(self,k):
- return k
- def hello(self,string):
- return string
- def __str__(self):
- with open("logfile", "r") as f:
- text = f.read()
- return text
- class blogger(logger):
- def popk(self,o):
- return o
- m = blogger()
- m.popk(9)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement