Message354385
Quick update on this feature: for the following example to work:
from inspect import is_decorator_call
def set_hello_tag(tag='world'):
if is_decorator_call():
# called without parenthesis!
# the decorated object is `tag`
return set_hello_tag()(tag) # note that `is_decorator_call` should not return True for this call
else:
def decorate(f):
setattr(f, 'hello', tag) # set a hello tag on the decorated f
return f
return decorate
Then `is_decorator_call` should be callable without arguments (default to current frame) and should return `True` only if the current frame is the one directly following decorator application. In nested frames (such as the one obtained after first recursive call to `set_hello_tag` above, `is_decorator_call` should return `False`. |
|
Date |
User |
Action |
Args |
2019-10-10 14:46:24 | smarie | set | recipients:
+ smarie, yselivanov |
2019-10-10 14:46:24 | smarie | set | messageid: <1570718784.89.0.760123357386.issue36553@roundup.psfhosted.org> |
2019-10-10 14:46:24 | smarie | link | issue36553 messages |
2019-10-10 14:46:24 | smarie | create | |
|