def __getitem__(self, key):
<EOL>if isinstance(key, int):<EOL><INDENT>return super(Choices, self).__getitem__(key)<EOL><DEDENT>if not hasattr(self, key):<EOL><INDENT>raise KeyError("<STR_LIT>" % key)<EOL><DEDENT>return getattr(self, key)<EOL>
Return the attribute having the given name for the current instance

        It allows for example to retrieve constant by keys instead of by attributes (as constants
        are set as attributes to easily get the matching value.)

        Example
        -------

        >>> MY_CHOICES = Choices(('FOO', 1, 'foo'), ('BAR', 2, 'bar'))
        >>> MY_CHOICES['FOO']
        1
        >>> MY_CHOICES['constants'] is MY_CHOICES.constants
        True