Giter Club home page Giter Club logo

data-enum's People

Contributors

chasefinch avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

data-enum's Issues

Prevent creating new Data Enum by accident

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.

Add syntax highlighting to Readme.md

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

Support default values for attributes

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 '$'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.