4 ms·
Could you not use mock.sentinel values as an enum? Also, you can create a poor man's enum from 2.7+ with: from collections import namedtuple myenum = n
by herge 13y ago
Could you not use mock.sentinel values as an enum? Also, you can create a poor man's enum from 2.7+ with:
from collections import namedtuple
myenum = namedtuple('myenum', ['a', 'b', 'c'])(range(3))
myenum.a == myenum.a
- viscanti 13y agoThat's not even a poor man's enum, it's just an enum. Named tuples can be used for everything an enum can be. This doesn't seem like a necessary PEP, but I've made my peace a long time ago about Python's bloated standard library. It's not the end of the world, and I still love Python, but this doesn't seem necessary to me.
- iso8859-1 13y agoYou don't have methods and you don't have a proper repr(). Also, even if you don't assign numbers, the fields are still ordered (which they shouldn't be).