Package can be defined as a directory consists of python files and a file with the name __init__.py.
In other words, it can be said that a directory which must consist a file named __init__.py is considered as a package.
A directory can contain subdirectories and files similarly a python package can have subpackage and module.
Let's take an example.Suppose we have to create a package of programming language.
Note:The above package is just for an example to understand.
As you can see in the above figure, we have a package named programming language in which we have 3 python files python.py,java.py,cpp.py. Also in this package we have__init__.py file which is must for package.
There can sub-packages in which files are placed under the package if you want.The above example is very simple in which there us a single package consist of some files.
We can import the file from package as below:
from programming_language import Python
Downloading a package is very easy.Let's consider we have to download a package called 'camelcase'.
For downloading a package , follow the given steps:
pip install packagename
Now as we installed the package. Here is the information about how to use that package.
We will use the following code to use the package:
import camelcase
c=camelcase.CamelCase()
text="python is one of the best programming language"
m=c.hump(text)
print(m)
Python is One Of The Best Programming Language
You will learn more about the packages in upcoming chapters. These are very helpful. These type packages are used in various field like Data Science, Deep Learning,Machine learning which are very important for the upcoming era.Therefore ,Python is considered as very important language and first choice for all of them who wanted to work in these fields.
You can also list out the installed packages in your system by typing the following code in Command Prompt.
pip list
The above command will list out all the packages which are installed in your system.