How to get Current Function Name in python / example

How to get Current Function Name in python / example


def Print(*args): 
    func_name = "[" + sys._getframe(1).f_code.co_name + "] "
    for value in args:
        if type(value) is str:
            func_name = func_name + value
        else:
            func_name = func_name + str(value)
    
    print(func_name)


Based on where the current syntax is running,

Function called with current syntax :
sys._getframe(0).f_code.co_name

Function with current syntax :
sys._getframe(1).f_code.co_name

#Python #PyQt #Python print #function #function Name

No comments:

Post a Comment

알뜰폰 삼성페이 교통카드 '한도 초과' 오류(등록 불가 오류) 해결방법

sk7mobile 알뜰폰 삼성페이 교통카드 등록 시, 한도 초과 문제 해결방법 skt usim 해킹 사건으로 인해 sk7mobile 알뜰폰을 사용하는 저도 usim을 바꾸고 나니 삼성페이 교통카드가 등록이 안되더라구요...  삼성페이 교통카드 기능 은...