Sylvain Marie <sylvain.ma...@schneider-electric.com> added the comment:
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`. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36553> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com