Python Forum

Full Version: Do you require imports used in other files?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Here is a snippet of code from two files:
# FileA.py
import time
def test():
    time.sleep(1)
    print("Hello")
# FileB.py
import FileA
test()
Will this print an error because FileA uses time, but FileB hasn't imported it? Or will it import time by itself?
Since time is only used in FileA.py, it will not print an error in FileB.
Call test() like this:
# FileB.py
import FileA
FileA.test()