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],
use building function type: document
>>> class X: ... a = 1 ... >>> X = type('X', (object,), dict(a=1))
first and second X are identical