{"library":"maybe-else","title":"Maybe-Else","description":"Provides a `Maybe` class as a Python implementation of null-aware operators. It allows for safe chaining of operations, attribute access, item access, and method calls on potentially `None` values, falling back to a default if `None` is encountered at any point. This helps avoid explicit `if var is not None` checks, similar to Optional/Maybe types in other languages. The library is currently at version 0.2.1, with its first and only release in November 2019.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install maybe-else"],"cli":null},"imports":["from maybe_else import Maybe"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from maybe_else import Maybe\n\n# Basic usage: providing a default for None\nresult1 = Maybe(None).else_(\"default value\")\nprint(f\"Result 1: {result1}\")\n\n# Chained operations on a non-None value\ndata = {'user': {'name': 'Alice', 'age': 30}}\nmaybe_name = Maybe(data)['user'].get('name').upper().else_('Unknown')\nprint(f\"Maybe name: {maybe_name}\")\n\n# Chained operations on a path with None\nmissing_data = {'user': None}\nmaybe_age = Maybe(missing_data)['user'].get('age').else_(0) # 'user' is None, so default is used\nprint(f\"Maybe age (missing user): {maybe_age}\")\n\n# Chained operations with a legitimate None as an intermediate result\ndef get_nullable_value(x):\n    return None if x % 2 == 0 else x\n\nresult_none_output = Maybe(2).map(get_nullable_value).else_('Fallback')\nprint(f\"Result None output (even number): {result_none_output}\") # Expected: None, not 'Fallback' (see warnings)\n\nresult_non_none_output = Maybe(3).map(get_nullable_value).else_('Fallback')\nprint(f\"Result Non-None output (odd number): {result_non_none_output}\")","lang":"python","description":"The `Maybe` class wraps a value, allowing subsequent attribute, item, or method calls to be chained. If any step in the chain encounters a `None` or raises a caught exception, the entire chain short-circuits, and `else_()` returns the provided default. Otherwise, the result of the final operation is returned.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"0.2.1","pypi_latest":"0.2.1","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":1.5,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"maybe-else","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"17.8M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"maybe-else","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.5,"import_time_s":null,"mem_mb":null,"disk_size":"18M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"maybe-else","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"19.6M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"maybe-else","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.6,"import_time_s":null,"mem_mb":null,"disk_size":"20M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"maybe-else","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"11.5M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"maybe-else","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.5,"import_time_s":null,"mem_mb":null,"disk_size":"12M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"maybe-else","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"11.3M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"maybe-else","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.4,"import_time_s":null,"mem_mb":null,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"maybe-else","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"17.3M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"maybe-else","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.7,"import_time_s":null,"mem_mb":null,"disk_size":"18M"}]}}