Smart {Code};

samuel-martins

Hi there, I am a full-stack developer. I love sharing my knowledge of development technologies and programming in general. Subscribe to get notified anytime I publish.

12 Likes Share

Have you ever been overwhelmed by the sheer number of python modules? Have you ever been stranded on picking the one to use for a specific project? In this article, I am going to be sharing with you some of the python modules that I believe every python developer should be familiar with. I am going to categorize these modules up into four different categories to make things a little bit easier.

. . .

1. Web Development

The first category of modules that I would like to discuss is those that deal with web development in HTTP requests. Python is heavily known for back-end web development, and therefore you could assume that there is a lot of different modules available to make enterprise-level websites in Python.


Requests

Python built-in modules ( urllib and urllib2 ) are used to handle HTTP related operation. Both modules come with a different set of functionalities, and many times they need to be used together. The main drawback of using urllib is that it is confusing in that few methods are available in both urllib, urllib2. Another drawback is that the documentation is not very clear, and we need to write a lot of code to make even a simple HTTP request. To make these things simpler, most developers prefer to use request as a third-party module instead. It is an Apache2 licensed HTTP library powered by urllib3 and httplib.


Django

Django is more of a high-level Python Web framework than a module, but you have to download and install it none the less. It takes care of the stress of building web apps from scratch. The main advantages of the framework include rapid development, pragmatic design, speed, and high scalability. You can also use other languages with it. You can connect it with other frameworks, and it comes with a lot of tools and complex developer features that allow you to make well enterprise-level websites.


Flask

Flask is also a web framework that usually competes with Django. The choice of which one to use for a web app is totally dependent on the project to be built. Flask is much easier and faster to get set up, and it does not come with all of the tools that come with Django. Django is best suited for applications with heavy features like authentication. Flask can be used for basic simple web apps.


BeautifulSoup

Beautiful soup is a great module for scraping the web. So if you are doing web scraping, beautiful soup can do that for you. It provides a few simple methods and Pythonic idioms for navigating, searching, and modifying a parse tree. It also converts incoming documents to Unicode and outgoing documents to UTF-8. You do not have to think about encodings unless the document does not specify an encoding, and Beautiful Soup cannot detect one, in which case you have to specify the original encoding. Beautiful Soup parses anything you give it and does the tree traversal stuff for you.


Selenium

Selenium is used to do automation on websites. This essentially allows you to either test your websites or to make a bot that will interact with other websites. So you could do things like accessing HTML fields, move your mouse cursor around, access buttons e.t.c I have used this before when I was working on a virtual assistant that would search the web for the information I asked it to. It could access the search bar, key in the search term, then go through the different results and pick one to follow. This module is powerful when used in the right way.

. . .


2. Data Science

Python is very popular for data science. It has a lot of different modules that are available to make the life of a data scientist much easier.


NumPy

Numpy is an amazing module for doing mathematical operations in Python. So what it allows you to do is work with array-like objects of multiple dimensions, and do all kinds of complicated, three-dimensional, four-dimensional, five-dimensional, math, very fast. One of the reasons it is so fast is because a lot of its operations are implemented in C, which means using NumPy will make your program a lot faster than if you were to say not use that module and implement those operations in standard Python.


Pandas

Pandas is great for reading and working with data frames and just data in general. It makes it very easy to manipulate data. It has a relatively steep learning curve, but it is well worth the effort. Pandas deals with data processing and analysis in five steps: load, prepare, manipulate, model, and analyze.


Matplotlib

Matplotlib is used for data visualization like making plots, charts, and it is also suitable for working with machine learning models. I know Matplotlib gets a lot of negativity, but this is mainly because of the confusion it causes new users since it has two interfaces. The first is based on MATLAB and uses a state-based interface. The second is an object-oriented interface. The reasons for the two are far too long to discuss in this particular article but knowing that there are two approaches is vitally important when plotting with Matplotlib.


NLTK

NLTK stands for natural language toolkit, and it is used for doing any data processing or text processing. So if you have textual data and you want to remove things like punctuation or spaces or tokenize your data.


OpenCV

OpenCV is a powerful module that is used for many different things. Its main focus is on image and video data processing. So we can do things like feature detection and description, object recognition, and it has machine learning tools built into the module that you can use to manipulate data or work with images.

. . .


3. Machine Learning and AI

This field commands a lot of attention, especially for where tech is moving. Almost everything these days runs some machine learning code. Self-driving cars, image recognition, personalized search, e.t.c


TensorFlow

TensorFlow is by far the most powerful module in this section. You can do some powerful things with it without really having a great understanding of how all the math works ( not that you should not geek out with math ). The benefit of TensorFlow is it allows you to create neural networks and run standard machine learning algorithms. I cannot stress enough how powerful this module is for those who are into machine learning. Maybe I will write another in-depth article on this later.


Keras

Keras is a module that is actually a higher-level API for TensorFlow. This module is usually more suitable for people who are just getting started in the field. Keras allows access to some of the TensorFlow features more easily. You can almost think of it as a wrapper for TensorFlow, where it just makes it much easier to make models and do things quickly.


Pytorch

I have not used this much, but I could not leave it out. It is another leading module in terms of machine learning and AI in Python. Pytorch boasts of two main features. The first is imperative programming as opposed to symbolic programming. An imperative program performs computation as you type. This feature makes the program more flexible. The second is dynamic computation graphing as opposed to static computation graphing. This means that at run-time, the system generates the graph structure, which works best for dynamic networks.


Scikit-learn

Scikit-learn is not as powerful as the previously mentioned modules. It is a little bit lighter weight and allows us to work with some things like clustering algorithms, linear progression, support, vector machines, and others. You could do these in TensorFlow, but it would be counterproductive to use a massive module for tasks that you can do with a lighter module.

. . .

4. Graphical User Interfaces in Python

Kivy

Kivy is a great module for actually building applications that will scale to all different platforms. Any Kivy app that you build will work on Linux, Mac, Windows, iOS, and Android.


PyQt5

In my opinion, this is the best graphical user interface builder for Python. It has the most options and flexibility in terms of what you can actually do with it. You can even use CSS styling to style your application. An example of something that is built with this module is the spyder IDE. If you want to make a more complex desktop application with Python, this should be the module that you pick.


Tkinter

Tkinter is an older module. It is also used for building graphical user interfaces. It is fairly similar to PyQt5 in terms of how the interfaces look, although it is definitely not as capable. I would say it is a little bit easier for beginners and people that are just looking to get something whipped up fast and pretty easily.

. . .


These are just a few that I believe every python developer going into any of the categories must know. Python is an amazing language to work with. This does not mean that you have to use everything it comes with. Some modules are better than others when it comes to different use cases. Choose the right tool for the job, and you’ll never go wrong.