pythonorm

pythonorm Git Source Tree


Root/enum.py

1
2
3
4
5
6
7
# Pythonic way to do enums:
def enum(*sequential, **named):
    enums = dict(zip(sequential, range(len(sequential))), **named)
    reverse = dict((value, key) for key, value in enums.iteritems())
    enums['val'] = reverse
    return type('Enum', (), enums)

Archive Download this file

Branches

Number of commits:
Page rendered in 0.22946s using 11 queries.