Member-only story
Python: Libraries you should use — Part-1
Hi, Welcome to this article of exploration into Python’s vast library ecosystem! In this segment, I will share some of the coolest Python libraries which have become essential in my coding journey and that I think you might don’t know about them.
Let’s dive in —
1. result
The concept of result
introduces the capability for parallel path programming. It facilitates the handling of errors represented through abstract data types, commonly known as monads or monadic structures.
These offer an alternative approach to error handling compared to using exceptions. Many individuals prefer this method over Python’s exception handling, as exceptions tend to disrupt the main program’s control flow.
This approach draws inspiration from functional programming principles. Instead of solely returning an alternative result value or raising an error, it allows for the return of a result
value, which can be either Ok
(value) or Err
(error). This design fosters clearer error management within the program’s structure.
Example —
using try/except block:
def divide(a: int, b: int) -> int:
try:
if b == 0:
raise…