Verifiably better, validated Enum
Project description
venum provides an Enum that is actually just a namedtuple, but easier to create. This means an Enum can be created during program execution and members are truly immutable (can’t dynamically add new ones). Also, this saves a bit of space over the stdlib’s Enum.
>>> from venum import Enum
>>>
>>> sample = Enum(('BLUE', 1), ('RED', 2))
>>> sample
Enum(BLUE=1, RED=2)
>>> sample.BLUE
1
>>>
>>> ContentTypes = Enum(
... ('JSON', 'application/json; charset=utf-8'),
... ('HTML', 'text/html; charset=utf-8'),
... ('JS', 'text/javascript; charset=utf-8'),
... ('XML', 'application/xml'),
... ('TEXT', 'text/plain; charset=utf-8'),
... ('JPEG', 'image/jpeg'),
... ('PNG', 'image/png'),
... ('YAML', 'application/x-yaml'),
... name='ContentTypes'
... )
>>> ContentTypes
ContentTypes(JSON='application/json; charset=UTF-8', HTML='text/html; charset=utf-8', JS='text/javascript; charset=utf-8', XML='application/xml', TEXT='text/plain; charset=utf-8', JPEG='image/jpeg', PNG='image/png', YAML='application/x-yaml')
Installation
venum is distributed on PyPI as a universal wheel and is available on Linux/macOS and Windows and supports Python 2.7/3.3+ and PyPy.
$ pip install venum
Final words
That’s really all there is to it, but if you’re keen on seeing more words that begin with the letter V, here’s V’s monologue from V for Vendetta.
“Voilà ! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate. This visage, no mere veneer of vanity, is a vestige of the vox populi, now vacant, vanished. However, this valorous visitation of a by-gone vexation, stands vivified and has vowed to vanquish these venal and virulent vermin vanguarding vice and vouchsafing the violently vicious and voracious violation of volition.
The only verdict is vengeance; a vendetta, held as a votive, not in vain, for the value and veracity of such shall one day vindicate the vigilant and the virtuous.
Verily, this vichyssoise of verbiage veers most verbose, so let me simply add that it’s my very good honor to meet you and you may call me V.”
—V
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 Distributions
Built Distribution
File details
Details for the file venum-1.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: venum-1.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c998e0724e406b977ec570cb7bb79799947060c20341bc1898cf608e0622bd09 |
|
MD5 | ea2e2337300949401ee7d960e07049ee |
|
BLAKE2b-256 | 11f1c5a9a653231489f401d748896ed09aa10e8cbe3f37e94a8beac1dd95bd54 |