On Mon, Oct 14, 2019 at 12:18 AM Steve Jorgensen <ste...@stevej.name> wrote: > class BrightColorsMeta(type): > def __rin__(self, other): > other.startswith('bright ') > > class BrightColors(metaclass=BrightColorsMeta): pass > > 'red' in BrightColors # -> False > 'bright blue' in BrightColors # -> True
For this specific example, have you looked at the enum module? https://docs.python.org/3/library/enum.html You can create a class that represents the enumeration, have members for each valid term, and then see if something is a part of the enumeration. ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/5NA5PAL54TED3YENOPAY6M5IE5P53OAN/ Code of Conduct: http://python.org/psf/codeofconduct/