This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ethan.furman
Recipients barry, eli.bendersky, ethan.furman, kissgyorgy
Date 2014-09-06.18:34:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1410028494.81.0.179066171152.issue22339@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2014-09-06 18:34:54ethan.furmansetrecipients: + ethan.furman, barry, eli.bendersky, kissgyorgy
2014-09-06 18:34:54ethan.furmansetmessageid: <1410028494.81.0.179066171152.issue22339@psf.upfronthosting.co.za>
2014-09-06 18:34:54ethan.furmanlinkissue22339 messages
2014-09-06 18:34:54ethan.furmancreate