[Python-checkins] bpo-42344: Improve pseudo implementation for SimpleNamespace (GH-23264)

ericvsmith webhook-mailer at python.org
Fri Nov 13 13:15:46 EST 2020


https://github.com/python/cpython/commit/bbeb2d266d6fc1ca9778726d0397d9d6f7a946e3
commit: bbeb2d266d6fc1ca9778726d0397d9d6f7a946e3
branch: master
author: Jürgen Gmach <juergen.gmach at googlemail.com>
committer: ericvsmith <ericvsmith at users.noreply.github.com>
date: 2020年11月13日T13:15:37-05:00
summary:
bpo-42344: Improve pseudo implementation for SimpleNamespace (GH-23264)
files:
M Doc/library/types.rst
diff --git a/Doc/library/types.rst b/Doc/library/types.rst
index ad40a9fbf3273..6f0dc259303fa 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`


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /