Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • Hello, I am getting below error when i run this: File "/usr/lib/python2.7/inspect.py", line 528, in findsource if not sourcefile and file[0] + file[-1] != '<>': IndexError: string index out of range Can u please provide suggestion. Thanx in advance. Commented Aug 13, 2014 at 11:07
  • This approach gave me an error: KeyError: 'main' Commented Oct 1, 2016 at 3:30
  • 2
    In Python 3 you need: print('caller name:', inspect.stack()[1][3]) Commented Mar 18, 2021 at 23:22