0
Define
import random for i in range(5): value = random.randint(1, 6) print(value) #When did we define randit? Assuming that random is already defined by someone.
3 Answers
+ 3
The import system scans the module and sets up its properties (etc) into global/local vars (so that you can refer to them)
import random
# directory of props, methods, vars...
print(dir(random))
# show the docstring
print(random.randint.__doc__)
+ 5
Try this variation of import to see what's available after import:
# globals() or locals()
print(globals(), "\n")
from random import *
# more toys!
print(globals(), "\n")
+ 1
It is defined in the random class object.