🔥 Burn Fat Fast. Discover How! 💪

Breaking news! Python3.10 was released several hours ago (not | Opensource Findings

Breaking news!

Python3.10 was released several hours ago (not so breaking news, right?). One of the main new features is pattern matching.

Today, I am releasing dry-python/returns@0.17.0 with full pattern matching support. Here's an example of how you can use it together with Result type:

from returns.result import Failure, Success, safe

@safe
def div(first_number: int, second_number: int) -> int:
return first_number // second_number

match div(1, 0):
# Matches if the result stored inside `Success` is `10`
case Success(10):
print('Result is "10"')

# Matches any `Success` instance and binds its value to the `value` variable
case Success(value):
print('Result is "{0}"'.format(value))

# Matches if the result stored inside `Failure` is `ZeroDivisionError`
case Failure(ZeroDivisionError):
print('"ZeroDivisionError" was raised')

# Matches any `Failure` instance
case Failure(_):
print('The division was a failure')

Cool, isn't it? Today Python made one more giant step for better functional programming support. And no doubt, that dry-python is the first one to officially support it.

Check out our:
- Docs: https://returns.readthedocs.io/en/latest/pages/result.html#pattern-matching
- Release notes: https://github.com/dry-python/returns/releases/tag/0.17.0
- Python3.10 release notes: https://docs.python.org/3.10/whatsnew/3.10.html

Soon we will be adding pattern matching support for mypy as well. So, it would be type checked correctly.

Big day for #python!