From bbeb2d266d6fc1ca9778726d0397d9d6f7a946e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Gmach?= Date: Fri, 13 Nov 2020 19:15:37 +0100 Subject: bpo-42344: Improve pseudo implementation for SimpleNamespace (GH-23264) --- 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 ad40a9f..6f0dc25 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` -- cgit v0.12