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
Metadata
Release files for enum-prop 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| enum-prop-0.0.1.tar.gz | 4.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| enum_prop-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.9 kB
Release files / enum-prop-0.0.1.tar.gz
| Download URL | enum-prop-0.0.1.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
77edfd912c1dfe795e9584b83b4c6890b993f33e3c7e59ec2d522f4ed8ae9167
|
|
BLAKE2b-256 checksum How to use checksums |
d313b0988c1f83d4dea2bfdbc7b162ed4e27dc7d85eae66eb28421fa615df863
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / enum_prop-0.0.1-py3-none-any.whl
| Download URL | enum_prop-0.0.1-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fe9a4a017f1bda19455018c05b212c2589f1d2dbea472dd6aa727d03458e4eda
|
|
BLAKE2b-256 checksum How to use checksums |
0aea4a1817780a77b744e3642fda48c4785fd7ba176f797abbe890f45434748f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|