this is a
that I wrote to output the log according to doc-string.
def log_attr(func):
"""doc-string"""
doc = func.__doc__
if func.__class__.__name__ == "property":
@property
def warpper(self, *args, **kwargs):
data = {}
data.update({"type_name": self.type_name})
if self.__class__.__name__ == "People":
data.update({"name": self.name})
elif re.match(r"Question|Column|Collection|Topic", self.__class__.__name__):
data.update({"name": self.title})
elif re.match(r"Answer|Article", self.__class__.__name__):
data.update({"name": self.author.name})
log(doc.format(**data))
return func.__get__.__call__(self, *args, **kwargs)
return warpper
when I use it as an attribute
@log_attr
@iter -sharp
@propery -sharp aaa()()
def aaa(x):
pass
shows that the AttributeError, object cannot find the property