mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-42344: Improve pseudo implementation for SimpleNamespace (GH-23264)
This commit is contained in:
parent
f97406be4c
commit
bbeb2d266d
1 changed files with 3 additions and 1 deletions
|
@ -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`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue