6. Modules and packages Flashcards
1
Q
installing a package
A
pip install xxxx
2
Q
what is a modules
A
module is just py.script
from mymodule import my_func
3
Q
what is a package
A
package is a bunch of modules
package needs to put a “__init__.py” file inside the folder
from mypackage import mymodule
4
Q
at the bottom of a .py script
A
if \_\_name\_\_ == "\_\_main\_\_": function 1() function 2()
5
Q
2 ways on importing built-in module
A
- import random
*when you use, “random.randint”
2a. from random import randint
*when you use, just randint()
2b from random import *
no need random. anymore