Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tombulled/arguments
Arguments manager
https://github.com/tombulled/arguments
Last synced: 23 days ago
JSON representation
Arguments manager
- Host: GitHub
- URL: https://github.com/tombulled/arguments
- Owner: tombulled
- License: mit
- Created: 2022-03-14T20:08:22.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-17T13:45:16.000Z (over 2 years ago)
- Last Synced: 2023-03-05T18:53:56.132Z (almost 2 years ago)
- Language: Python
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# arguments
Arguments manager## Usage
### `Arguments`
#### Instantiation
```python
from arguments import Argumentsargs = Arguments("Hello", "World", sep=", ")
```
```python
>>> args
Arguments("Hello", "World", sep=", ")
```#### Attributes
```python
>>> args.args
("Hello", "World")
>>> args.kwargs
{"sep": ", "}
```#### Iteration
```python
>>> tuple(args)
("Hello", "World", ", ")
>>> len(args)
3
```#### Invokation
```python
>>> args.call(print)
Hello, World
```#### Partial
```python
>>> func = args.partial(print, end="!")
>>> func(sep="-")
hello-world!
```#### Union
```python
>>> Arguments("hello", sep=", ") | Arguments("world", sep="-")
Arguments("hello", "world", sep="-")
```### `BoundArguments`
#### Instantiation
```python
from arguments import Arguments, BoundArgumentsdef foo(message: str, exclaim: bool = False) -> None:
...args: Arguments = Arguments("Hello, World")
bound_args: BoundArguments = args.bind(foo)
```
```python
>>> bound_args
BoundArguments("Hello, World", False)
```#### As Dictionary
```python
>>> bound_args.asdict()
{"message": "Hello, World", "exclaim": False}
```#### Get
```python
>>> bound_args.get("message")
"Hello, World"
```#### Has
```python
>>> bound_args.has("message")
True
```