SimpleNamespacetype from the
typeslibrary provides an alternative to an empty class (
class MyClass: pass) from which one can add and remove attributes.
import types enki = types.SimpleNamespace() enki.type = 'God' print(enki.type) # God del enki.type print(enki.type) # object has no attribute 'type'
objectsubclass that provides attribute access to its namespace, as well as a meaningful repr.
SimpleNamespaceyou can add and remove attributes. If a
SimpleNamespaceobject is initialized with keyword arguments, those are directly added to the underlying namespace.
SimpleNamespacemay be useful as a replacement for
class NS: pass. However, for a structured record type use