title: How to create objects on the fly in python?
body: <p>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:</p>
  
  <pre><code>{'test': [a1, a2, b2], 'test2': 'something else', 'test3': 1}
  </code></pre>
  
  <p>which makes the template look untidy. so I think it's better to just create an object which is like:</p>
  
  <pre><code>class testclass():
      self.test = [a1,a2,b2]
      self.test2 = 'someting else'
      self.test3 = 1
  testobj = testclass()
  </code></pre>
  
  <p>so I can do:</p>
  
  <pre><code>{{ testobj.test }}
  {{ testobj.test2 }}
  {{ testobj.test3 }}
  </code></pre>
  
  <p>instead of calling the dictionary.</p>
  
  <p>Since I just need that object once, is it possible to create it without writing a class first? Is there any short-hand code? Is it ok to do it like that or is it bad Python?</p>