How do I create objects on the fly in Python? I often want to pass information to my Django templates which is formatted like this:
{\'test\': [a1, a2, b2],
for the sake of completeness, there is also recordclass:
recordclass
from recordclass import recordclass Test = recordclass('Test', ['test', 'test1', 'test2']) foo = Test(test=['a1','a2','b2'], test1='someting else', test2=1) print(foo.test) .. ['a1', 'a2', 'b2']