Kiss György added the comment:

> Is this a way to easily handle multiple aliases?

You mean this MultiValueEnum implementation? (If not I don't understand the 
question, could you elaborate?)

No, this is the opposite of aliases, because an alias is when the same value 
have multiple names, but this is when the values are used to lookup the same 
name.

I use it when very similar values have the same meaning like:

    class Suit(MultiValueEnum):
        CLUBS =    '♣', 'c', 'C', 'clubs', 'club'
        DIAMONDS = '♦', 'd', 'D', 'diamonds', 'diamond'
        HEARTS =   '♥', 'h', 'H', 'hearts', 'heart'
        SPADES =   '♠', 's', 'S', 'spades', 'spade'


Also it can be used for ECP testing (Equivalence class testing) like this:

    from http.client import responses
    class ResponseEnum(MultiValueEnum):
        GOOD = [status for status in responses if 200 <= status <= 299]
        BAD = [status for status in responses if not (200 <= status <= 299)]

I did not think about this use case, but I think it's very interesting and 
useful.

----------

_______________________________________
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