Hidden Gems of Python

Libraries and Features of Python that I had no idea even existed

Hidden Gems of Python

Libraries and Features of Python that I had no idea even existed

Python is one of the foremost widely-used programming languages within the world of knowledge science and machine learning. It’s a shallow learning curve and it comes with a large variety of libraries similarly to packages that make it quite widespread amongst developers. Python libraries are a gaggle of modules that contour the event method for the developers.

These days, I even have new Python documentation only for fun! After you browse one thing at leisure, you tend to note fascinating tidbits that you just would have been incomprehensible otherwise. So, here is the list of tidbits that created Pine Tree State go, “Will you do this in Python?”

For this reason, I decided to begin a collection of articles that will reveal a number of the options that I contemplate the simplest and small famed gems offered within the commonplace library.

For-else loop

In Python, you’ll be able to add an associate degree else clause to a for a loop. The else clause is triggered providing no break statement was encountered at intervals in the body of the loop throughout execution. Notice that the else is indented at the amount of for and not at the amount of if. So, the break statement can ne’er be encountered.

Hence, the else clause can get triggered and print the output shown higher than. One may argue that this might be achieved by employing a separate variable that keeps track of whether or not the break statement was encountered.

Web Applications and WSGI

For internet applications, it is easy to use this pattern to the WSGI perform so it’s adorned to send any request crash. There are solutions offered for any WSGI compatible internet framework that offers middlewares that will lure any application failure.

From the TurboGears2 internet framework which will be used with the other framework and has no dependency on TurboGears itself. The backlash additionally includes support for reporters like the sentinel one which will organise your crashes on the sentinel rather than causing them by email, therefore you do not have to be compelled to combination them yourself.

Report code crashes using logging

Many people understand the python work module, however, fewer individuals understand that it will log not simply messages, however additionally tracebacks. And even fewer understand that it is organized with a collection of terribly versatile and powerful message handlers that will be able to send the logged messages everyplace. From the foremost obvious case of causing those messages to log files, to leverage the SysLog protocol, causing them through networks or maybe across emails.

By configuring the lumberjack with a correct handler, we can have our logged messages sent by email. this can enable the U.S.A. to receive a notification when one thing is logged into that lumberjack.


Data analysis and image is that the most vital however tedious method. Bamboolib could be a GUI developed for pandas DataFrames that permits developers to seamlessly work with Python in Jupyter Notebook or JupyterLab. it’s well-known as an associate degree intelligent and extremely accessory library to analyse, imagine, and manage info. It is utilized by even people UN agency do not return from a programming background because it doesn’t need any secret writing data.


Missingo will facilitate in managing the missing values by leverage information visualisations additional effectively. supported matplotlib, Missingo has four types of plotsto higher perceive {the information|the info|the information} that’s missing data. These contain bar charts, heatmap, matrix, similarly to a dendrogram.

Separators for ‘int’

It’s exhausting to tell apart visually between integers like 10000000 and 100000000. {we can’t|we can not|we won’t} use commas here in Python as we tend to use them in English as a result of Python will interpret it as a tuple of multiple integers.

Python features a terribly convenient method of addressing this: we can use underscore as a centrifuge to boost readability. Thus, 1_000_000 are understood as one int.


One of the foremost underrated libraries that are used for activity explorative tasks associated with information analysis. The library helps in information image tasks and may handle even massive datasets. one code is wont to retrieve information image. simply inclose the JSON, CSV, or txt file and therefore the library mechanically helps in the image.

eval() and exec()

Python has the flexibility to dynamically browse a string and treat it sort of a piece of Python code. this is often achieved victimisation eval() and exec() functions (‘eval’ is for evaluating expressions and ‘exec’ is for capital punishment statements).

In line 3, the eval() perform can browse the input string as a Python expression, assess it, and assign the result to the variable ‘b’. In line 6, exec() perform can browse the input string as a Python statement and execute it.