def __eq__(self, other):
if isinstance(other, str):<EOL><INDENT>try:<EOL><INDENT>other = self.construct_from_string(other)<EOL><DEDENT>except TypeError:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>if isinstance(other, type(self)):<EOL><INDENT>return all(<EOL>getattr(self, attr) == getattr(other, attr)<EOL>for attr in self._metadata<EOL>)<EOL><DEDENT>return False<EOL>
Check whether 'other' is equal to self.

        By default, 'other' is considered equal if either

        * it's a string matching 'self.name'.
        * it's an instance of this type and all of the
          the attributes in ``self._metadata`` are equal between
          `self` and `other`.

        Parameters
        ----------
        other : Any

        Returns
        -------
        bool