title: How to pass arguments to the metaclass from the class definition?
body: <p>I'm trying to dynamically generate classes in python 2.7, and am wondering if you can easily pass arguments to the metaclass from the class object.</p>
  
  <p>I've read <a href="https://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python">this</a> post, which is awesome, but doesn't quite answer the question.  at the moment I am doing:</p>
  
  <pre><code>def class_factory(args, to, meta_class):
      Class MyMetaClass(type):
          def __new__(cls, class_name, parents, attrs):
              attrs['args'] = args
              attrs['to'] = to
              attrs['eggs'] = meta_class
  
      class MyClass(object):
          metaclass = MyMetaClass
          ...
  </code></pre>
  
  <p>but this requires me to do the following</p>
  
  <pre><code>MyClassClass = class_factory('spam', 'and', 'eggs')
  my_instance = MyClassClass()
  </code></pre>
  
  <p>Is there a cleaner way of doing this?</p>