What are modules really for?

Terry Reedy tjreedy at udel.edu
Thu Aug 11 21:31:58 CEST 2005

"Brian Quinlan" <brian at sweetapp.com> wrote in message 
news:42FB55BC.70608 at sweetapp.com...
> There is a difference between everything being an object and everything
> being an instance of a class. In Python, every runtime entity is an
> object but not everything is a class instance.

However, everything is an instance of a class or type.  And once old-style 
classes are dropped, all classes will be user-defined types and types will 
be built-in classes.  And it seems that for instances of such unified 
type-classes, type(x) == x.__class__:
>>> type(int)
<type 'type'>
>>> int.__class__
<type 'type'>
>>> class c(object): pass
>>> c1 = c()
>>> type(c1)
<class '__main__.c'>
>>> c1.__class__
<class '__main__.c'>
# don't know if user metaclasses can change this or not

So the distinction, if kept, will be pretty thin.

Terry J. Reedy

More information about the Python-list mailing list