Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/keuin/anodict

Annotated Python dict.
https://github.com/keuin/anodict

Last synced: about 1 month ago
JSON representation

Annotated Python dict.

Awesome Lists containing this project

README

        

# anodict: annotated dict

[![Pyversions](https://img.shields.io/pypi/pyversions/anodict.svg?style=flat-square)](https://pypi.org/project/anodict/)

Convert a `dict` to an annotated object.

# Usage

## Installation

```shell
pip install anodict
```

## Example

```python
import anodict

class Person:
name: str
age: int

person = anodict.dict_to_class({
"name": "bob",
"age": 23
}, Person)

print("type:", type(person))
print("name:", person.name)
print("age:", person.age)
```

will give:

```
type:
name: bob
age: 23
```