bpo-42344: Improve pseudo implementation for SimpleNamespace (GH-23264) (GH-23269)
(cherry picked from commit bbeb2d266d
)
Co-authored-by: Jürgen Gmach <juergen.gmach@googlemail.com>
Co-authored-by: Jürgen Gmach <juergen.gmach@googlemail.com>
This commit is contained in:
parent
5ad468d4a8
commit
cb2b2035ca
|
@ -355,7 +355,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…
Reference in New Issue