급질문) 파이썬 제너레이터가 안됩니다.

smreo의 이미지

트랜잭션의 흐름이 현재 어느 모듈, 어느 함수, 소스의 몇 번째 행을 돌고 있는지 알고 싶어서 아래와 같이 했습니다.
/usr/lib/python3.6/pfFunc.py

import inspect
 
def FrameDecor(func):
    def decorated():	
        callerframerecord = inspect.stack()[1]    # 0 represents this line
                                                  # 1 represents line at caller
        frame = callerframerecord[0]
        info = inspect.getframeinfo(frame)
        print (" ==> in <<", info.filename, ">> Line:",info.lineno, " Func:", info.function)
        func()                    # original function
        print (" ==> out <<", info.filename, ">> Line:",info.lineno, " Func:", info.function)
    return decorated                      

그리고 테스트를 아래와 같이 했습니다.

import pfFunc 
 
@FrameDecor 
def message1() :
    print("--- Generator Test --- ")  
 
message1()

그러면 결과가 이렇게 나옵니다.
Traceback (most recent call last):
File "testF.py", line 6, in
@FrameDecor
NameError: name 'FrameDecor' is not defined

pfFunc를 호출하지 않고 모듈 내에서는 잘 됩니다. 왜 이럴까요? 도와 주세요.

읽어주셔서 감사합니다. 끝.

File attachments: 
첨부파일 크기
Plain text icon pfFunc.py.txt644바이트
Plain text icon testF.py.txt182바이트
익명 사용자의 이미지

@pfFunc.FrameDecor

smreo의 이미지

2년 전에도 같은 짓거리를 했었는데..., 그땐 이렇게 애먹지 않았는데요.
덕분에 데코레이터로 클래스까지 만들어 놨습니다.
근데 갑자기 환경이 윈도우즈로 바뀌네요. -.-