Skip to main content

An Option container class that handles seamlessly NoneType checks in a monadic way.

Project description

opt4py

Adds to Python an Option container class that handles seamlessly NoneType checks in a monadic way. Similar to Option in Rust or Optional in Java, but it also overloads every operator for a smooth use without worries.

Usage

>>> from opt4py import Option
>>> Option(1)
Option(1)
>>> Option("Hello World!")
Option(Hello World!)
>>> Option()
Option(None)
>>> Option(1) + 1
Option(2)
>>> Option(2) * Option(2)
Option(4)
>>> Option(5).unwrap()
5
>>> Option(8).map(lambda x: x*2)
Option(16)
>>> Option(2) == 2
True
>>> Option(2) > 3
False

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opt4py-1.0.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

opt4py-1.0.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file opt4py-1.0.0.tar.gz.

File metadata

  • Download URL: opt4py-1.0.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for opt4py-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d970699d9bb0e9687e54af01b3cd550df5c473136d78cfdac436fdaa17ff95bc
MD5 cb1a478df60fec4ebf727d1d956f02ea
BLAKE2b-256 d2f9cb04e1214281d2880d495245d7cded7653e69b5d95d703fecb17ad707f70

See more details on using hashes here.

File details

Details for the file opt4py-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: opt4py-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for opt4py-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 884b868bd0c168bc513553ebdbff392dd8048abea5612a94691d4dd31d25cc8c
MD5 eceb7f5a910d773e942067e3bbe04110
BLAKE2b-256 a66bbfbdd31695aa7e15591f4702a0c0998bc1dbaee18c4ffd3cf02f723e8be8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page