From cb2b2035ca752529755440990c4073d5164e80df Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Fri, 13 Nov 2020 10:18:35 -0800 Subject: bpo-42344: Improve pseudo implementation for SimpleNamespace (GH-23264) (GH-23269) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit bbeb2d266d6fc1ca9778726d0397d9d6f7a946e3) Co-authored-by: Jürgen Gmach Co-authored-by: Jürgen Gmach --- Doc/library/types.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Doc/library/types.rst b/Doc/library/types.rst index 71d7a12..998816b 100644 --- a/Doc/library/types.rst +++ b/Doc/library/types.rst @@ -355,7 +355,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` -- cgit v0.12