chasefinch / data-enum Goto Github PK
View Code? Open in Web Editor NEWPython enumerations alternative with attached data
Home Page: https://pypi.org/project/data-enum/
License: Apache License 2.0
Python enumerations alternative with attached data
Home Page: https://pypi.org/project/data-enum/
License: Apache License 2.0
As an unfortunate side effect of the design, it is easy to create a new Enum member by accident in the global namespace without realizing it. It would be good for a design improvement or some kind of safety net to prevent users from accidentally monkeypatching a DataEnum.
Cool project, thank you for doing this. It is incredibly useful.
In the readme, all the examples look bland, like for e.g
Minimal usage:
from data_enum import DataEnum
class Currency(DataEnum):
data_attributes = ('symbol', 'name')
Currency('CAD', symbol='$', name='Canadian dollar')
Currency('USD', symbol='$', name='United States dollar')
Currency('EUR', symbol='€', name='Euro')
Using the github markdown code tags, specifically,
\``` py
code_here
\```
it could look like this
from data_enum import DataEnum
class Currency(DataEnum):
data_attributes = ('symbol', 'name')
Currency('CAD', symbol='$', name='Canadian dollar')
Currency('USD', symbol='$', name='United States dollar')
Currency('EUR', symbol='€', name='Euro')
Just a quick suggestion, it works for other languages too
Would be good to have some attributes allow a default value that's set when the attribute name is omitted. This might mean that the syntax for "is_unique" needs to be more explicit. For example:
class Currency(DataEnum)
data_attributes = (
('code', dict(is_unique=True)), # Simple syntax ('code', True) would also still be allowed
('symbol', dict(default='$')),
)
Currency.CAD = Currency(code='CAD') # Uses default symbol '$'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.