Ad
  • Custom User Avatar

    Python 3.7.3 (default, Dec 20 2019, 18:57:59)
    Type 'copyright', 'credits' or 'license' for more information
    IPython 7.14.0 -- An enhanced Interactive Python. Type '?' for help.

    In [1]: def xyz():
    ...: return globals()[import('inspect').stack()[0][3][6]]
    ...:

    In [2]: xyz()

    IndexError Traceback (most recent call last)
    in
    ----> 1 xyz()

    in xyz()
    1 def xyz():
    ----> 2 return globals()[import('inspect').stack()[0][3][6]]
    3

    IndexError: string index out of range

    In [3]: