def func(val): return a.func(val)
import a #a.py를 import import test print("top-level : b.py") a.func() if __name__ == "__main__": print('b.py를 직접 실행') else: print("b.py를 import 시켜서 실행")
from a import X, func, C Y = X * func() + C().m()
#file b.py import a print ("from b.py") a.func() if __name__ == "__main__": print ("b.py is being run directly") else: print ("b.py is being imported by a different file")
import os import sys from a import func print("start calling function from a.py") print("AAA") func() print("BBB") print("done") os._exit(0)