Functional utilities for Python, inspired by Scala
Project description
fython
Functional utilities for Python, inspired by Scala
FOptional
from fython import option
def my_function():
return (option(something_that_might_return_none())
.map(do_something)
.map(do_another_thing)
.get_or_else(default_value))
@dataclass
class Inner:
v: Optional[str]
@dataclass
class Outer:
inner: Optional[Inner]
c = Outer(Inner("hello"))
inner_value = (option(c)
.flatmap(lambda c: c.inner)
.flatmap(lambda inner: inner.v)
.get_or_throw())
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
fython-0.0.4.tar.gz
(2.2 kB
view details)
File details
Details for the file fython-0.0.4.tar.gz.
File metadata
- Download URL: fython-0.0.4.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0.post20201221 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aae525562978cf4b123a089f21c461987e7b8d8f60f18d58269bc409a367af6d
|
|
| MD5 |
41401d307d8025feba717ddb2dd67940
|
|
| BLAKE2b-256 |
c5f9bf2798505a10d4c6db028c335732591cfe24bb5cb5ad9b15679cb99d5f19
|