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 kissgyorgy
Recipients barry, eli.bendersky, ethan.furman, kissgyorgy
Date 2014-09-06.14:26:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1410013585.45.0.904286108748.issue22339@psf.upfronthosting.co.za>
In-reply-to
Content
I found one thing which you can't do subclassing Enum what you can with metaclasses:
enforcing type checking at class creation time. Values are passed to __new__ as positional arguments, so it's impossible to tell the difference between these two:

class SingleValue(MultiVAlueEnum):
    one = 1, 'one'
    two = 2


class Tuple(MultiVAlueEnum):
    one = 1, 'one'
    two = 2,

because in both cases (2,) would be passed. It's not a big deal, but "Explicit is better than implicit." and also I would like to avoid typos, which I often make like this:

class StrValues(MultiValueEnum):
    one = ('One'
          'one')
    two = ('two',
          'Two')

In this case, the first member would be accepted as 'Oneone' instead of ('One', 'one') and I see no way to check that without metaclasses. Do you?
History
Date User Action Args
2014-09-06 14:26:25kissgyorgysetrecipients: + kissgyorgy, barry, eli.bendersky, ethan.furman
2014-09-06 14:26:25kissgyorgysetmessageid: <1410013585.45.0.904286108748.issue22339@psf.upfronthosting.co.za>
2014-09-06 14:26:25kissgyorgylinkissue22339 messages
2014-09-06 14:26:25kissgyorgycreate