From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Fri, 13 Nov 2020 18:19:05 +0000 (-0800) Subject: bpo-42344: Improve pseudo implementation for SimpleNamespace (GH-23264) (GH-23270) X-Git-Tag: v3.9.1rc1~48 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4defeb007195d2d17ea404b0b6291d1d233010f4;p=thirdparty%2FPython%2Fcpython.git bpo-42344: Improve pseudo implementation for SimpleNamespace (GH-23264) (GH-23270) (cherry picked from commit bbeb2d266d6fc1ca9778726d0397d9d6f7a946e3) Co-authored-by: Jürgen Gmach Co-authored-by: Jürgen Gmach --- diff --git a/Doc/library/types.rst b/Doc/library/types.rst index 5d68c6852678..0fe3822fa542 100644 --- a/Doc/library/types.rst +++ b/Doc/library/types.rst @@ -384,7 +384,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`