10000 bpo-42344: Improve pseudo implementation for SimpleNamespace (GH-23264) · python/cpython@bbeb2d2 · GitHub
[go: up one dir, main page]

Skip to content

Commit bbeb2d2

Browse files
authored
bpo-42344: Improve pseudo implementation for SimpleNamespace (GH-23264)
1 parent f97406b commit bbeb2d2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Doc/library/types.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,9 @@ Additional Utility Classes and Functions
409409
return "{}({})".format(type(self).__name__, ", ".join(items))
410410

411411
def __eq__(self, other):
412-
return self.__dict__ == other.__dict__
412+
if isinstance(self, SimpleNamespace) and isinstance(other, SimpleNamespace):
413+
return self.__dict__ == other.__dict__
414+
return NotImplemented
413415

414416
``SimpleNamespace`` may be useful as a replacement for ``class NS: pass``.
415417
However, for a structured record type use :func:`~collections.namedtuple`

0 commit comments

Comments
 (0)
0