Message226501
You could do the same kind of check in __new__, but consider this:
class StrValues(MultiValueEnum):
one = ('One'
'one',
'1')
two = ('two',
'Two',
'2')
In this scenario the 'Oneone' mistake would still not be automatically caught. There are the two ways I deal with this type of problem:
- unit tests
- formatting
The formatting looks like this:
class StrValues(MultiValueEnum):
one = (
'One'
'one',
'1',
)
two = (
'two',
'Two',
'2',
)
This style of format does several things for us:
- easier to read the code:
- each value is on it's own line
- each value is lined up
- there is white space between the values of one attribute and
the values of the next attribute
- easier to read diffs, as we don't see extraneous stuff like
- '2'
+ '2',
- easier to spot mistakes, since we get used to seeing that trailing
comma and it's absence will stand out. |
|
Date |
User |
Action |
Args |
2014-09-06 18:34:54 | ethan.furman | set | recipients:
+ ethan.furman, barry, eli.bendersky, kissgyorgy |
2014-09-06 18:34:54 | ethan.furman | set | messageid: <1410028494.81.0.179066171152.issue22339@psf.upfronthosting.co.za> |
2014-09-06 18:34:54 | ethan.furman | link | issue22339 messages |
2014-09-06 18:34:54 | ethan.furman | create | |
|