Implement __contains__ ('x' in Choices('x')) for Choices objects.

In Choices, `_choice_dict` appears to be a definitive location of all
internal/DB representations, so it seems the best target for finding
out if the given item is part of the sequences.
This commit is contained in:
Keryn Knight 2013-08-02 12:23:48 +01:00
parent 369f9f8ced
commit f89369f9ac

View file

@ -76,3 +76,7 @@ class Choices(object):
def __repr__(self):
return '%s(%s)' % (self.__class__.__name__,
', '.join(("%s" % repr(i) for i in self._full)))
def __contains__(self, item):
if item in self._choice_dict.values():
return True