본문 바로가기
관리자

Programming-[Backend]/Python

[링크] python circular import 해결 - import time, runtime

728x90
반응형

 

py 파일 맨 위쪽에서 import 하지말고, 함수 선언문이나 실행문 속에서 from ... import ...을 하면 된다.

 

 

맨 위쪽 import는 파이썬이 처음 실행을 위해 import문들을 모두 스캔할 때 import하는 것이고,

함수 선언문이나 실행문에서의 import는 실제로 그 함수가 불릴때(runtime) import하는 것이다.

 

 

https://blog.mathpresso.com/python-circular-imports-e89c5bf16510

 

Python Circular Imports

Python Circular Imports가 무엇이며, 오류는 어떻게 해결할까?

blog.mathpresso.com

 

 

728x90
반응형