3

Given something like this:

@my_decorator
my_function(some, args)

Is it possible for my_decorator to discover the file and line number my_function was called from?

Thanks

russell_h
  • 956
  • 2
  • 9
  • 18
  • 2
    It's not possible for the *decorator*, only for the *decorated function* (i.e. the decorator's return value). I suppose that's what you mean? – balpha Jan 08 '10 at 06:50
  • Yeah, thanks for clarifying that, I've been a bit confused about the terminology surrounding decorators. – russell_h Jan 08 '10 at 16:44

1 Answers1

4

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

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358