In programming, a package is a directory or folder containing a collection of modules. These modules can be seen as files or documents contained collectively in a folder called package. Packages are a bundled collection of modules in python serving a specific purpose. An example we can use to explain further is a library and how it works. We can think of this collection of packages like a traditional real world library. Each package is a book or magazine and this library gets bigger everyday. In python, there are currently 10’s of 10,000 of packages to choose from.
You import packages the same way you import modules, using import statements. However, in the case of packages, you have to use the keywords “import from”. Let’s take a look at this example:
Let’s say you want to import a package “foo”.
Now the code above wont work unless you make use of the keyword “import from” to specifically mention the module you want to use from the package “foo” . The code below shows how the code should be written:
where “foo” is the package and “a” is the module we want to get from the package.
Exploring the packages directory structure or referring to code blocks online can save time. To work with packages in python, it’s important to know that PIP is it’s default package manager and PyPI(Python Package Index) is the package index where you can find unpublished packages.
Python has an extensive collection of packages. As a developer starting out, it can be overwhelming but understanding what python is most widely used for today first can help. Therefore, the major application areas of python are:
With this in mind, packages can be grouped into the following categories:
We shall now explore each of these categories in details briefly.
These are packages that do not need to be installed separately. They can be used as soon as you have installed python on your system. Almost every project uses one or more of this built-in packages and as a developer, it is of great advantage to you if you know them well. The most popular ones are OS, SYS, CSV, JSON, importlib, remath and intertools.
In the world of data science, the most popular python packages are Numpy, Scipy, NLTK and pandas. They are used for data exploration and manipulation. Other packages like openCV and matplotlib are used for image processing and data visualisation.
Within the world of ML and AI, the most popular packages are tensorflow, PyTorch and keras. PyTorch and keras are the most popular for deep learning and neuro network implementation. There are also other packages such as Scipy, Scikit-Learn and Theano.
The most popular packages are FLASK(a lightweight microframe work ) and Django(a full stack framework). Other popular web development packages include cherry pie, pyramid, beautiful, soup and selenium.
As a developer, choosing what package to use will depend on the scale and scope of the project and how familiar you become with the package in question. But as a beginner though in using python code, most functions you will need can be met by one package so on the long run, there may be little need for you to learn more than you can handle. In conclusion, python has a wide range of packages which can be used for various fields and also provides a level of diversity for us as developers.
Introduction Python is a programming language that has a large sum of frameworks. One of…
Introduction What is Cloud Computing? According to Wikipedia, Cloud Computing is a paradigm for enabling…
Introduction In the fast paced world of technology, learning a versatile and high-in-demand programming language…
Introduction User Authentication policy is a very crucial process for every application and organization. It…
Introduction In previous articles, we have learnt about Django, how it works and how we…
Introduction In this article, we shall learn how to build and implement a blog app.…