Tidy enum properties
Project description
enum-prop
Enum definitions can't, for good reasons, reference instances of themselves within their own definitions. This module allows definitions to come around that by mapping the names of enums for lookups, hidden behind a special dict subclass. This allows enum definitions to remain tidy, and avoids having to define instance-specific configuration as property functions.
Installation
$ python3 -m pip install enum-prop
Usage
import enum
from enum_prop import enum_property, enum_getter
class Vehicle(enum.Enum):
car = "car"
bike = "bike"
unicycle = "unicycle"
wheels = enum_property({car: 4, bike: 2, unicycle: 1})
__int__ = enum_getter({car: 4, bike: 2, unicycle: 1})
print(Vehicle.unicycle.wheels) # 1
print(Vehicle.car.wheels) # 4
print(int(Vehicle.unicycle)) # 1
print(int(Vehicle.bike)) # 2
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file enum-prop-0.0.1.tar.gz.
File metadata
- Download URL: enum-prop-0.0.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77edfd912c1dfe795e9584b83b4c6890b993f33e3c7e59ec2d522f4ed8ae9167
|
|
| MD5 |
a8ff4b86ee9e315a3eeb7922fad4d080
|
|
| BLAKE2b-256 |
d313b0988c1f83d4dea2bfdbc7b162ed4e27dc7d85eae66eb28421fa615df863
|
File details
Details for the file enum_prop-0.0.1-py3-none-any.whl.
File metadata
- Download URL: enum_prop-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe9a4a017f1bda19455018c05b212c2589f1d2dbea472dd6aa727d03458e4eda
|
|
| MD5 |
25977689c53124bbd7666ac495cee559
|
|
| BLAKE2b-256 |
0aea4a1817780a77b744e3642fda48c4785fd7ba176f797abbe890f45434748f
|