0

What does the "import" in import random mean?

2nd Apr 2017, 2:44 AM
Alex
1 Resposta
+ 1
it tells Python you wish to import a group of functions for use in your script. Random isn't a function that exists in your empty script. By importing random you gain access to the random functions located outside of your script. *Note ... Do not create a file called random.py .. it will screw up your import and random will stop working The reason for that is you can use functions from your other scripts by importing the script. if you had a script called calculator.py and it had a method to add().. you could have a new script and say import calculator calculator.add() Accessing the add() function of your calculator script.. When you name a file random.py, you override the built in random module and when you import random, you import your script instead
2nd Apr 2017, 3:05 AM
LordHill
LordHill - avatar