Skip to main content

Useful descriptor for shadow stat collections

Project description

KeeWee 🥝

Useful descriptor for recording and statistic generation.

Example:

Just define your Python classes or dataclasses as you would normally do.
If you are using dataclasses you should remove your shadowing fields from the repr as they will mess up your results in the end.

from dataclasses import dataclass, field

from keewee import KeeWee


@dataclass
class PokemonTrainer:
    name: str
    skill_level: int | KeeWee = field(default=KeeWee(), repr=False)

A common usage would look like

import random

ash = PokemonTrainer(name="Ash Ketchum", skill_level=0)

for _ in range(10):
    ash.skill_level = random.randint(1, 10)

print(KeeWee.dumpd())

Result

{'PokemonTrainer':
    {'skill_level':
        {"PokemonTrainer(name='Ash Ketchum')": {
            '13:08:36.055042': 0,
            '13:08:36.055055': 5,
            '13:08:36.055059': 1,
            '13:08:36.055061': 5,
            '13:08:36.055064': 2,
            '13:08:36.055066': 5,
            '13:08:36.055069': 10,
            '13:08:36.055071': 6,
            '13:08:36.055073': 6,
            '13:08:36.055075': 6,
            '13:08:36.055077': 4
        }
        }
    }
}

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

keewee-0.0.8.tar.gz (15.2 kB view hashes)

Uploaded Source

Built Distribution

keewee-0.0.8-py3-none-any.whl (15.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page