def __eq__(self, other):
if isinstance(other, str):<EOL><INDENT>return other == self.name<EOL><DEDENT>elif other is self:<EOL><INDENT>return True<EOL><DEDENT>elif not (hasattr(other, '<STR_LIT>') and hasattr(other, '<STR_LIT>')):<EOL><INDENT>return False<EOL><DEDENT>elif self.categories is None or other.categories is None:<EOL><INDENT>return True<EOL><DEDENT>elif self.ordered or other.ordered:<EOL><INDENT>return ((self.ordered == other.ordered) and<EOL>self.categories.equals(other.categories))<EOL><DEDENT>else:<EOL><INDENT>return hash(self) == hash(other)<EOL><DEDENT>
Rules for CDT equality:
1) Any CDT is equal to the string 'category'
2) Any CDT is equal to itself
3) Any CDT is equal to a CDT with categories=None regardless of ordered
4) A CDT with ordered=True is only equal to another CDT with
   ordered=True and identical categories in the same order
5) A CDT with ordered={False, None} is only equal to another CDT with
   ordered={False, None} and identical categories, but same order is
   not required. There is no distinction between False/None.
6) Any other comparison returns False