###### tags: python
# Modules
to organize codes
every .py is a module
Packing related modules in folder(package)
in package must create `__init__.py`
`from package.package.module import function`
usually use
`from package.package import module` to prevent overwritting function
`from module import fuction`
`from module import *` to import all function in module
by useing above ways, we can just call fuction without typing the package name as well as module name
`if __name__ == '__main__':` is given specifically when we run the main file(`__main__`) to only run code on main file
we can download the thrid party modules by pip
pip3 install pyjokes==0.4 ->appoint specific version of package
venv(virtual envirnoment) - to customize the envirnoment you want exclusively
## Useful built-in modules
- collection (from collections import Counter, defaultdic, OrderDict)
```
li = [1,2,3,4,5,6,7]
sentence = 'blah blah blah thinking about python'
print(Counter(li))
```
```
dictionary = defaultdict(lambda: 'does not exist', {'a':1,'b':2})
print(dictionary['c'])
```
```
d = OrderDict()
d['a'] = 1
d['b'] = 2
d2 = OrderDict()
d2['a'] = 1
d2['b'] = 2
```
- datetime (import datetime)
datetime.time(5,45,2)
datetime.date.today()
- time(from time import time)
- array(from array import array)
array('i', [1,2,3])