def p(): import sys print sys._getframe(1).f_code.co_name def f(): p() def f1(): p() if __name__ == '__main__': f() f1()