diff options
author | Jürgen Gmach <juergen.gmach@googlemail.com> | 2020-11-13 18:15:37 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-13 18:15:37 (GMT) |
commit | bbeb2d266d6fc1ca9778726d0397d9d6f7a946e3 (patch) | |
tree | affcf057592e7c84ce85a2fa12e98a3d59899b88 /Doc/library | |
parent | f97406be4c0a02c1501c7ab8bc8ef3850eddb962 (diff) | |
download | cpython-bbeb2d266d6fc1ca9778726d0397d9d6f7a946e3.zip cpython-bbeb2d266d6fc1ca9778726d0397d9d6f7a946e3.tar.gz cpython-bbeb2d266d6fc1ca9778726d0397d9d6f7a946e3.tar.bz2 |
bpo-42344: Improve pseudo implementation for SimpleNamespace (GH-23264)
Diffstat (limited to 'Doc/library')
-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 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` |