DEV Community

Ken Harrison
Ken Harrison

Posted on • Originally published at python.plainenglish.io on

5 of my favourite Python Libraries you need to try!

developer image to accompany the article: a guy on his laptop with headphones on

5 favorite Python Libraries you need to try!

Python is a popular programming language that has a wide range of libraries and tools available for various tasks. In this article, weโ€™ll take a quick look at five libraries that can be particularly useful for automating tasks, creating cloud infrastructure, formatting code, and managing dependencies.

๐Ÿ“ฃ Notes : None of the following library is not a built-in library in Python, so you will need to pip install each library. I have linked the home page of all the libraies.


File & Folder Management

Is your desktop disorderly? You are unable to locate anything in your documents and downloads. Is it too time-consuming to manually sort and rename all of these files? Itโ€™s time to automate it once so you can profit from it always.

organize: is a Python library that allows you to automate repetitive tasks by writing a simple YAML config file. The library provides a simple command line that makes it easy to interact with the underlying operating system, such as running commands and reading and writing files. This can save a lot of time and effort, especially when working with large amounts of data or when performing tasks that need to be done frequently.

Here is an example of the YAML file

rules:
  - name: "Find PDFs"
    locations:
      - ~/Downloads
    subfolders: true
    filters:
      - extension: pdf
    actions:
      - echo: "Found PDF!"

Enter fullscreen mode Exit fullscreen mode

Here is a simulation of how I clean my downloads folders:

A Gif of the organize python library in action
gif of the organize library cleaning my downloads folder

_organize library logo_


For Cloud Computing

You donโ€™t want to waste time connecting ten AWS services to create a website or backend?

pulumi: pulumi is a Python library that makes it easy to create, update, and manage cloud infrastructure using code. It allows you to write infrastructure as code (IaC) using Python, which can be more efficient and easier to understand than using a web-based interface or a configuration file. With pulumi, you can define your infrastructure using Python classes and methods, and the library will take care of provisioning and updating resources on various cloud providers such as AWS, Azure, Google cloud and more.

You can view a host of examples here .

pulumi library logo


Code Formatting

Do you want to spend more time focusing on your logic and code solution and less on formatting along the way?

black: black is a popular Python library that helps you format your code automatically. It can help you to keep your code consistent and easy to read, by automatically applying a set of rules to your code. Black is especially useful when working on large codebases with multiple contributors, as it can help to ensure that everyoneโ€™s code looks the same.

black has a playground for you to see its magic at work

_black library logo_


Handling Date & Time

Need a simplify way to handle date and time?

  1. pendulum: pendulum is a library for handling dates and times in Python. It provides a simple and easy-to-use API for working with dates and times, and it is compatible with the datetime module in the Python standard library. The pendulum library provides a lot of additional functionality such as localization and support for time zones, advanced formatting options and more.

Example:

import pendulum

now = pendulum.now("Europe/Paris")

# Changing timezone
now.in_timezone("America/Toronto")

# Default support for common datetime formats
now.to_iso8601_string()

# Shifting
now.add(days=2)
Enter fullscreen mode Exit fullscreen mode

_Pendulum library logo_

Dependency Management

Need to manage your package with ease and at scale ?

poetry: poetry is a Python dependency management tool that makes it easy to install and manage your Python dependencies. It allows you to declare your dependencies in a single file, and it will handle installing them and creating a virtual environment for your project. Poetry can also be useful for packaging and publishing your own Python packages. It makes the process of creating, publishing and distributing python packages easy and consistent.

Here is a great article to get you started with poetry

Gif of the python poetry library installation

So to sum up, organize, pulumi, black, pendulum, and poetry are five powerful Python libraries that can help you automate tasks, create and manage cloud infrastructure, format your code, handle dates and time and manage dependencies respectively. They are widely used in many Python projects and have proven to be very effective and useful. If you are looking for ways to make your work easier and more efficient, these libraries can be a great way to get started.


Top comments (0)