开发者

See What Line a Function Was Called From in Python Decorator

开发者 https://www.devze.com 2022-12-15 23:32 出处:网络
Given something like this: @my_decorator my_function(some, args) Is it possible for my_decorator to d开发者_JAVA技巧iscover the file and line number my_function was called from?

Given something like this:

@my_decorator
my_function(some, args)

Is it possible for my_decorator to d开发者_JAVA技巧iscover the file and line number my_function was called from?

Thanks


traceback.extract_stack() will allow you to examine the current stack frame.

0

精彩评论

暂无评论...
验证码 换一张
取 消