Kiss György added the comment:

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?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22339>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to