From: Jürgen Gmach Date: Fri, 13 Nov 2020 18:15:37 +0000 (+0100) Subject: bpo-42344: Improve pseudo implementation for SimpleNamespace (GH-23264) X-Git-Tag: v3.10.0a3~208 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bbeb2d266d6fc1ca9778726d0397d9d6f7a946e3;p=thirdparty%2FPython%2Fcpython.git bpo-42344: Improve pseudo implementation for SimpleNamespace (GH-23264) --- diff --git a/Doc/library/types.rst b/Doc/library/types.rst index ad40a9fbf327..6f0dc259303f 100644 --- a/Doc/library/types.rst +++ b/Doc/library/types.rst @@ -409,7 +409,9 @@ Additional Utility Classes and Functions return "{}({})".format(type(self).__name__, ", ".join(items)) def __eq__(self, other): - return self.__dict__ == other.__dict__ + if isinstance(self, SimpleNamespace) and isinstance(other, SimpleNamespace): + return self.__dict__ == other.__dict__ + return NotImplemented ``SimpleNamespace`` may be useful as a replacement for ``class NS: pass``. However, for a structured record type use :func:`~collections.namedtuple`