Jun-11-2019, 07:16 PM
(This post was last modified: Jun-11-2019, 07:17 PM by Gribouillis.)
You can use built-in collections.namedtuple objects to create immutable records with named fields. If you prefer the mutable version, there is one in the module namedlist in pypi
>>> from namedlist import namedlist >>> Sns = namedlist('Sns', ['test', 'testing', 'ing'], default=None) >>> s = Sns('spam', 'eggs', 'bacon') >>> s Sns(test='spam', testing='eggs', ing='bacon') >>> s.test 'spam' >>> s.testing 'eggs' >>> s.test = 'foo' >>> s Sns(test='foo', testing='eggs', ing='bacon')