Module to set predefined allowed values for a variable
Project description
Enumy
The problem with Python's "Enum" module is that it is not a reasonable way to restrict variables to a predefined set of values.
Latest version: v1.0.2
Installation
pip install --user enumy
Special methods
check_type
Check if a variable matches a certain data type.
var.check_type(str)
check_value
Check if a value is present in the allowed values.
text = "ByteSentinel"
var.check_value(text)
Example
from enumy import Enumy
test = Enumy(("Value 1", "Value 2"), str)
test = "Value 2" # Working
test = 123 # Exception
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
enumy-1.0.2.tar.gz
(1.9 kB
view details)
Built Distribution
enumy-1.0.2-py3-none-any.whl
(2.1 kB
view details)
File details
Details for the file enumy-1.0.2.tar.gz
.
File metadata
- Download URL: enumy-1.0.2.tar.gz
- Upload date:
- Size: 1.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d2ec0bb45af7ad70767d6a851457813e5136d85f54c23b02027106bc4d78d9d |
|
MD5 | 9e7c4ae4da94c01e6945a91f57415f28 |
|
BLAKE2b-256 | dd202b53ee142b825518ae75e1e79eb515e5ef4299179f556f7c2a018a5ec09f |
File details
Details for the file enumy-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: enumy-1.0.2-py3-none-any.whl
- Upload date:
- Size: 2.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a0e2b1b4c55673ed3affe5e70be25ba3dc8bfb2ef5ba18b5850e22d25a96c7a |
|
MD5 | 725454a3bf411d350e717a445594453c |
|
BLAKE2b-256 | 38a5b6d5e020360094f8c22e7e0d5c212978264f0e73d673b680ef2c90758fa4 |