On Mon, Oct 14, 2019 at 12:18 AM Steve Jorgensen <[email protected]> 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 -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/5NA5PAL54TED3YENOPAY6M5IE5P53OAN/ Code of Conduct: http://python.org/psf/codeofconduct/
