Ethan Furman added the comment:
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.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue22339>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com