Python real world applications
Maciej Mazurek, 20 January 2020
Python is very often used by scientists from various fields. It is used by bioinformatics, engineers, mathematicians, astronomers and cognitive scientists. Below are some of the tools available in Python used in specific fields of science.
The most popular Python package used in Bioinformatics is Biopython. It supports Clustal, FASTA and GenBank file formats. It has also build in data analysis methods such as k Nearest Neighbors, Naive Bayes and Support Vector Machines.
Astropy is a Python package that enjoys the greatest recognition among astronomers. Astropy handles FITS files and time series. It also provide tools for coordinate conversion.
Python has gained popularity among matematicians mainly due to the SciPy package, which is often considered as an alternative to the commercial MatLab language, or even, in some cases, as an alternative to the famous Matematica program. Below we will list those SciPy components that are especially useful for mathematicians.
Numpy is a library adding support for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays. It also contains random number generator and tools for computing Fourier transforms.
It is used to create charts, graphs and graphical presentation of data. It contains a pyplot module, which in combination with IPyhon is a very good alternative to the MatLab console.
The goal of the project is, as you can read on the official website, to create a complete computer algebraic system while maintaining the simplicity of the code. With Sympy, you can, for example, define and manipulate finite groups.
Shell with a built-in Python interpreter. It can be used for interactive data visualization, also has built-in tools for performing multi-threaded calculations.
In addition to extensive scientific applications, Python is an increasingly popular language for creating commercial systems and applications. In the following part of the article, we describe the most popular technologies in individual areas of software development and give an example of their occurrence in IT products known to us from everyday life.
This area has recently seen many spectacular successes. Neural networks have revolutionized IT by solving many problems that had until then been unsolvable. Below we present, along with examples of use, the most popular tools written in Python for implementing artificial intelligence.
A popular tool for creating artificial intelligence is the TensorFlow library created by the Google Brain team. Uber programmers used TensorFlow to create the Michalangelo platform. This platform is used, among others, to predict the delivery time of food ordered through the UberEATS application.
Framework created by a team of Facebook scientists as an alternative to TensorFlow. It was used to create Pyro, a propabilistic language developed by Uber programmers. PyTorch is also used by Facebook or Twitter.
Among many Python WEB frameworks, the most popular are Django and Flask.
Dajngo was created by programmers working for the Lawrence Journal-World newspaper. It has many ready-made solutions such as users authorization system, (ready to use and easy to configure) admin dashboard and Object-Relational Mapping (a tool for communicating with databases). Also, there are a lot of external packages created by the community that can be easily used in Django projects.
Django is used among others by companies such as Spotify, Instagram, Dropbox, Youtube, Google and even by NASA.
Flask is a lightweight tool that is more of a library collection than a framework. Interestingly, it was created as part of an April Fool’s joke referring to the previous, not very successful, web micro framework “Bottle”. Flask evolved over time and became a serious project that is still being developed.
Flask, unlike Django, does not have a built-in ORM system, administrator panel or other ready-made solutions. Because of this, the time of needed for creating large and complicated web applications using Flask is, usually, significantly longer than when using Django. On the other hand, Flask leaves much more freedom, while Django somehow imposes certain design solutions in advance.
Popular web applications based on Flask include Netflix, reddit, Banksalad and Zalando.
Python can also be used to create desktop applications. The most popular tools include frameworks such as PyQt or Kivy. Below we will briefly describe each of them.
PyQt is a Python adapter on the Qt framework written in C ++. It’s latest version, PyQt5, is compatible with many platforms: Windows, Linux, Mac OS or even Android and iOS. PyQt was used to create applications such as caliber, cross-platform application for managing and editing e-books, or the Dropbox desktop client.
Unlike PyQt, Kivy is a tool better suited for creating applications for mobile devices, although among the supported platforms in addition to Android and iOS are also Windows, Mac OS and GNU / Linux. Examples of the most recognizable products created using Kivy are 100 days of fitness and 2048 (available in the App Store).
Automation / Continuous Integration
Creating and maintaining software is an iterative process. The introduction of any modification requires the programmer to perform many tedious technical activities such as testing, uploading to the server (in the case of web applications) or static code analysis. Repeating the same procedures for each change increases probability of mistakes and consumes time.
Therefore, for larger projects, it is worth automating all these activities, e.g. by writing one script that will be responsible for their proper execution. Python is great for this. Thanks to built-in subprocess and os libraries, scripting in Python is easy.
It is also worth mentioning that Python has built-in tools for writing automated tests. The unittest module allows you to create simple unit tests. If you organize the project structure properly, you can run all your tests with single console command.
There are several tools for creating games in Python. By far the most popular of them is PyGame. However, it should be clearly stated that there is no commercial known game created using PyGame. PyGame is a tool created by and for the community. On the internet you can find many open-source games written in PyGame, which look more like old GameBoy games, than modern GameDev industry productions.
However, it is not entirely true that Python is not used to create computer games. Such well-known titles as The Sims 4 or Civilization IV use Python as a scripting language or a tool for creating mods.
Internet of Things
Internet of Things is a concept that says that generally understood objects (lighting, household appliances, watches or even footwear) can collect, process and exchange data (hence the name “Internet of Things”). Of course, to implement this concept, each of the “items” in the network must contain the proper software.
Despite its low performance, Python is used to program devices such as Raspbery pi. Although it is rather unsuitable for writing software that works close to hardware (such as C language), thanks to its easy configuration, portability and the availability of many packages that facilitate, e.g. data processing, it is a good tool for programming more high-level components.