Metadata-Version: 2.4
Name: dictclasses
Version: 1.0.0
Summary: A simple yet powerful decorator to create custom classes with dict-like behavior.
License: MIT
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: hjson
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: summary

# dictclasses

A simple yet powerful decorator to create custom classes with dict-like behavior.

## Installation

```bash
pip install dictclasses
```

## Description

`dictclasses` provides the `@dictclass` decorator that transforms any Python class into a dict-like object. The decorated class accepts a dictionary as its first argument and exposes all standard dictionary methods (`keys`, `values`, `items`, `get`, `pop`, `update`, etc.) while allowing you to define custom methods and properties.

## Usage

### Basic usage

```python
from dictclasses import dictclass

@dictclass
class Person:
    @property
    def full_name(self):
        return f"{self['first_name']} {self['last_name']}"

person = Person({"first_name": "John", "last_name": "Doe"})
print(person["first_name"])  # John
print(person.full_name)      # John Doe
print(person.keys())         # dict_keys(['first_name', 'last_name'])
```

### From JSON / HJSON files

```python
@dictclass
class Config:
    pass

config = Config.from_json("config.json")
# or
config = Config.from_hjson("config.hjson")
```

### Available methods

The decorator adds the following dict methods (unless already defined in the class):

- `__getitem__`, `__setitem__`
- `__len__`, `__iter__`
- `keys`, `values`, `items`
- `get`, `pop`, `popitem`
- `copy`, `deepcopy`
- `update`, `clear`, `setdefault`
- `fromkeys`
- `from_json`, `from_hjson` (class methods)
