How does the following work in python:
def f(num):
time.sleep(num)
return num
>>> f(2)
NameError: name 'time' is not defined
>>> import time
>>> f(2)
2
How does python "insert" the module into that function, or how does the lookup mechanism work there as to be able to import something after the function is created?