-
Notifications
You must be signed in to change notification settings - Fork 3
Modules
Modules are pieces of code already written earlier which can be used in your program to reuse the logic
written in that file.
Every python file is in itself is a module. When someone wants to use the logic written in this file, this file is a module for that file.We can import the functions/classes from module using:
import <modulename>or
from <modulename> import <functionName>
or
from <modulename> import <functionName> as <aliasName>
and then call the function as :
<modulename>.<functionName>()
or
<functionName>()
or
<aliasName>()
sys.path refers to your Python’s system path. This is the list of
directories that Python goes through to search for modules and files or your current directory.
To add your python modules to sys.path, so you can import them easily using below code .
import sys
if 'drive:\\yourModulesFolder' not in sys.path:
sys.path.append('drive:\\yourModulesFolder')
3 types of Modules
1. written by own
2. Standard Library: libraries pre-installed from Python.
3. External third- party libraries
Many Third-party python modules are stored on the Python Package Index.
PyPi.
To install these applications,pip command can be used which is provided
by default with modern distribution of Python.
-> pip install <libraryname>
Keep Learning. Never Settle! 😊
- Home
- 1.Introduction To Python
- 2. DataTypes
- 3. Strings and Slicing of collection
- 4.If else & Loops
- 5. Break, continue, pass
- 6. Functions
- 7. Modules
- 8. Clarifying basics
- 9. File Handling
- 10. Exception Handling
- 11. Dig into Collections
- 12. Iterators, Generators and list comprehension
- 13. lambdas , map, filter and other concepts
- 14. args, kwargs an default parameters
- 15. Functional Programming
- 16. OOPs