[Python-3000] Types and classes

Paul Prescod paul at prescod.net
Wed Apr 2 23:57:14 CEST 2008


Apologies if this has been discussed before.

But does anyone else find it odd that the types of some things are
classes and the classes of some things are types?

>>> type(socket.socket())
<class 'socket.socket'>
>>> type("abc")
<type 'str'>
>>> socket.socket().__class__
<class 'socket.socket'>
>>> "abc".__class__
<type 'str'>

In a recent talk I could only explain this as a historical quirk. As I
understand, it is now possible to make types that behave basically
exactly like classes and classes that behave exactly like types. Is
there any important difference between them anymore?

 Paul Prescod


More information about the Python-3000 mailing list