diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-11-13 18:19:05 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-13 18:19:05 (GMT) |
commit | 4defeb007195d2d17ea404b0b6291d1d233010f4 (patch) | |
tree | 7992d8a2e69a6ee26a40dd1bf708fe6be24ae99f | |
parent | 0f4dd87a31130b245ec4c6ded9fd6f247e700c0d (diff) | |
download | cpython-4defeb007195d2d17ea404b0b6291d1d233010f4.zip cpython-4defeb007195d2d17ea404b0b6291d1d233010f4.tar.gz cpython-4defeb007195d2d17ea404b0b6291d1d233010f4.tar.bz2 |
bpo-42344: Improve pseudo implementation for SimpleNamespace (GH-23264) (GH-23270)
(cherry picked from commit bbeb2d266d6fc1ca9778726d0397d9d6f7a946e3)
Co-authored-by: Jürgen Gmach <juergen.gmach@googlemail.com>
Co-authored-by: Jürgen Gmach <juergen.gmach@googlemail.com>
-rw-r--r-- | Doc/library/types.rst | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Doc/library/types.rst b/Doc/library/types.rst index 5d68c68..0fe3822 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` |