Name | joptional JSON |
Version |
0.1.1
JSON |
| download |
home_page | None |
Summary | Exact implementation of Java's Optional in Python with 100% test coverage. |
upload_time | 2024-04-16 13:25:19 |
maintainer | None |
docs_url | None |
author | Tobias Waslowski |
requires_python | <4.0,>=3.7 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# pyoptional
Java-style Optionals for Python.
## Installation
Simply install this package with your favourite package manager:
pip install pyoptional
or
poetry install pyoptional
## Usage
The `Optional` class is a generic class that can be used to wrap a value that may or may not be `None`.
Its functionality is roughly equivalent to Java's `Optional` class. For example:
```java
Optional<String> opt = Optional.of("Hello, world!");
opt.ifPresent(System.out::println);
```
turns to the following Python code:
```python
opt = Optional[str].of("Hello, world!")
opt.if_present(print)
```
Of course, type annotations in Python are optional (no pun intended),
so you can simply write `Optional.of("Hello, world!")` if you prefer.
Raw data
{
"_id": null,
"home_page": null,
"name": "joptional",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.7",
"maintainer_email": null,
"keywords": null,
"author": "Tobias Waslowski",
"author_email": "tobiaswaslowski@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ab/05/13769d90ed406183da93ab344befc3c8d0b31a8ddf52e8163ad6a5867081/joptional-0.1.1.tar.gz",
"platform": null,
"description": "# pyoptional\n\nJava-style Optionals for Python.\n\n## Installation\n\nSimply install this package with your favourite package manager:\n\n pip install pyoptional\n\nor\n\n poetry install pyoptional\n\n## Usage\n\nThe `Optional` class is a generic class that can be used to wrap a value that may or may not be `None`.\nIts functionality is roughly equivalent to Java's `Optional` class. For example:\n\n```java\nOptional<String> opt = Optional.of(\"Hello, world!\");\nopt.ifPresent(System.out::println);\n```\n\nturns to the following Python code:\n\n```python\nopt = Optional[str].of(\"Hello, world!\")\nopt.if_present(print)\n```\n\nOf course, type annotations in Python are optional (no pun intended),\nso you can simply write `Optional.of(\"Hello, world!\")` if you prefer.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Exact implementation of Java's Optional in Python with 100% test coverage.",
"version": "0.1.1",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4f75d515e0155819c25db77adcd4a759eca54678ba0fdbfb2585dcc9d9fffbac",
"md5": "7722a52c4c1af13b92be724bc30c89cb",
"sha256": "486613262a099264ffff651f116915c489b05b8049555cb97153a0678daa32d7"
},
"downloads": -1,
"filename": "joptional-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7722a52c4c1af13b92be724bc30c89cb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.7",
"size": 2716,
"upload_time": "2024-04-16T13:25:17",
"upload_time_iso_8601": "2024-04-16T13:25:17.947931Z",
"url": "https://files.pythonhosted.org/packages/4f/75/d515e0155819c25db77adcd4a759eca54678ba0fdbfb2585dcc9d9fffbac/joptional-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ab0513769d90ed406183da93ab344befc3c8d0b31a8ddf52e8163ad6a5867081",
"md5": "a8cea7fb34e8c0c1963a7f12162e5924",
"sha256": "c0de90542ab016451ee41a2bbc562a1c50869b61ef1b5706c75ebfa3670a82b0"
},
"downloads": -1,
"filename": "joptional-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "a8cea7fb34e8c0c1963a7f12162e5924",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.7",
"size": 2331,
"upload_time": "2024-04-16T13:25:19",
"upload_time_iso_8601": "2024-04-16T13:25:19.647488Z",
"url": "https://files.pythonhosted.org/packages/ab/05/13769d90ed406183da93ab344befc3c8d0b31a8ddf52e8163ad6a5867081/joptional-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-16 13:25:19",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "joptional"
}