Creating new classes on the fly

Mike C. Fletcher mcfletch at rogers.com
Tue Oct 5 17:03:23 EDT 2004


Carlos Ribeiro wrote:
...

>I've found two different ways to do it in the documentation:
>
>new.classobj(name, baseclasses, dict)
>  
>
This creates an old-style class (new.classobj being the old-style 
metaclass).

>type(name, bases, dict)
>  
>
This creates a new-style class (i.e. with property support, 
super-support, you know, the fun stuff).

>I assume that both end up calling the same code, but I really don't
>know which one am I supposed to call, in terms of being the most
>'pythonic' way. Are both the same? Is one of them preferred over the
>other?
>  
>
New code should likely be using type.

HTH,
Mike

________________________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com




More information about the Python-list mailing list