2 Antworten
+ 4
"from <module> import <submodule>" allows you to import a certain submodule (=> randrange) from a module (=> random).
"import random" imports all the submodules from random and you can use random.randrange, random.gauss etc. in your code to access these submodules.
"from random import randrange" will only import randrange and you can access it with "randrange" (no need to write "random.randrange" (<= in fact that would be wrong)). But you won't be able to use random.randint(), random.random() or other submodules because you only imported randrange.
+ 1
thanks