A Primer on Python Metaclass Programming
Subject:   type not the same as new.classobj
Date:   2007-07-13 16:17:19
From:   hattawayd
In the text you mention: "The class type works as a class factory in the same way that the function new.classobj does"

I'm not sure what the whole different is, but there is a difference.
One example that bit me with Python2.5:

>>> test = new.classobj('test', (), {'a1': 'tA1'})
>>> test.__dict__
{'a1': 'tA1', '__module__': '__main__', '__doc__': None}

>>> test = type('test', (), ('test', (), {'a1': 'tA1'})
>>> test.__dict__
<dictproxy object at 0x00963A70>

So if your code, or the libraries you're using (in my case Django) depend on the value __dict__ then make sure to use the right one.

1 to 1 of 1
  1. type not the same as new.classobj
    2007-07-13 17:09:41  David_Mertz [View]

1 to 1 of 1