Relative and Absolute Imports
- We have imported our own modules from
- current directory
- subdirectory
- python Standard Library
- All the examples of imports done so far are referred as absolute imports.
import utils
- Python supports relative imports
- if utils.py in the same directory
from . import utils
- if utils.py is in the parent directory
from .. import utils
- if utils.py in the same directory
- Refer Here for the changeset to fix the No Module utils found by using relative imports
Writing and importing our Module
- Create the following folder structure
- In the models Folder create a module called as
- models.py
- In the viewmodels add operations module (operations.py)
- define a function inside operations.py which will create a new employee by asking from users Refer Here
- Refer Here for the resolution of the import issue
Python Standard Library
- One of the pythons prominent claims is that it has "batteries include" a large standard library of modules that perform many useful tasks are shipped along with python installation.
- They are kept seperate to avoid bloading the core language. Refer Here for the official docs
Print Nicely with pprint()
- Refer Here for the official documentation
- Refer Here for the sample created in classroom
Get Random
- For random standard library documentation Refer Here Refer Here
Text Related Standard Libraries
- string Refer Here
- textwrap Refer Here
- difflib Refer Here