'new' module deprecation in python2.6

Christian Heimes lists at cheimes.de
Sat Nov 29 12:52:12 EST 2008


David Pratt wrote:
> Hi Mike. Many thanks for your reply and thank you for reference.  I have 
> code that looks like the following so initially looking at what will 
> need to be done as it doesn't appear new will survive. So first need to 
> find way of translating this sort of thing using types. I see there is a 
> ClassType for types in Python 2.6 but it does not exist in Python 3 so 
> wonder where this is going? Is this an oversight or maybe just not ready 
> yet.

ClassType is the type of old style classes. Since old style classes were 
removed the ClassType is also gone.

You can create new style classes with type:

 >>> Name = type("Name", (object,), dict(spam="egg"))
 >>> Name
<class '__main__.Name'>
 >>> Name.spam
'egg'

Christian




More information about the Python-list mailing list