Discovering a library that massively simplifies the exact thing you just did right after you’ve finished doing the thing you needed to do has to be one of the top 14 worst things about writing code. You might think it’s a part of the life we’ve all chosen, but it doesn’t have to be. Beyond the popular libraries you already know lies a treasure trove of under appreciated packages waiting to be wielded. Being the saint I am, I’ve scoured the depths of pypi.org to find some underrated and hopefully useful packages to make your life a little easier.
1. Arrow: Mastering the Art of Dates and Times
Ever wrestled with Python’s built-in datetime
module? Arrow comes to the rescue, offering a more intuitive and user-friendly approach to handling dates and times. Parsing, formatting, manipulating, and performing calculations on dates becomes a breeze. Arrow is adept at human-readable formatting, making timestamps in user interfaces or logs crystal clear. It can also handle time zones effortlessly.
2. Humanize: Making Data Speak the Human Language
Imagine a world where complex numbers and dates transform into easily understandable information. Humanize simplifies the conversion of data into human-readable formats. Whether it’s adding commas to large numbers for better comprehension or converting timestamps into user-friendly phrases like “4 weeks ago”.
3. Loguru: The Debugging Detective
Never use a print statement again. Loguru is a Python logging library designed to make logging easier and more flexible. It provides a simple and intuitive interface for logging messages with various levels of severity.
4. IceCream: The Debugging Detective
Maybe you’re not quite ready to give up using print statements for debugging in your debugging. Enter, IceCream. It’s a library that enhances the debugging process by providing a simple and expressive way to print variables and expressions during code execution. It offers an alternative to traditional print statements with a concise syntax that automatically includes the variable name and value, making debugging more informative and efficient.
5. Pydantic: Data Guardians and Configuration Champions
Not really underrated but still useful, Pydantic takes the responsibility of data validation and settings management off your shoulders. It ensures data types are as expected, handles optional and default values, and manages configuration settings with ease.
6. Typer: Building User-Friendly Command Line Interfaces
Think command-line interfaces but easier. ArgParse but better. –{input} but prettier. Typer offers a straightforward way to define commands, arguments, and options using type annotations, allowing developers to create CLIs quickly and intuitively.