backlinks to this page:
Plugin Backlinks: Nothing was found.
Github:
Python object
class types.SimpleNamespace A simple object subclass that provides attribute access to its namespace, as well as a meaningful repr.
Unlike object, with SimpleNamespace you can add and remove attributes. If a SimpleNamespace object is initialized with keyword arguments, those are directly added to the underlying namespace. https://docs.python.org/3.8/library/types.html#types.SimpleNamespace
code is like:
class SimpleNamespace: def __init__(self, /, **kwargs): self.__dict__.update(kwargs) def __repr__(self): keys = sorted(self.__dict__) items = ("{}={!r}".format(k, self.__dict__[k]) for k in keys) return "{}({})".format(type(self).__name__, ", ".join(items)) def __eq__(self, other): 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 namedtuple() instead.