[Python-checkins] bpo-42344: Improve pseudo implementation for SimpleNamespace (GH-23264) (GH-23270)
ericvsmith
webhook-mailer at python.org
Fri Nov 13 13:19:09 EST 2020
https://github.com/python/cpython/commit/4defeb007195d2d17ea404b0b6291d1d233010f4
commit: 4defeb007195d2d17ea404b0b6291d1d233010f4
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: ericvsmith <ericvsmith at users.noreply.github.com>
date: 2020-11-13T13:19:05-05:00
summary:
bpo-42344: Improve pseudo implementation for SimpleNamespace (GH-23264) (GH-23270)
(cherry picked from commit bbeb2d266d6fc1ca9778726d0397d9d6f7a946e3)
Co-authored-by: Jürgen Gmach <juergen.gmach at googlemail.com>
Co-authored-by: Jürgen Gmach <juergen.gmach at googlemail.com>
files:
M Doc/library/types.rst
diff --git a/Doc/library/types.rst b/Doc/library/types.rst
index 5d68c6852678c..0fe3822fa542e 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`
More information about the Python-checkins
mailing list