Difference between type and class

oj ojeeves at gmail.com
Thu Jul 31 07:29:45 EDT 2008


On Jul 31, 11:37 am, Nikolaus Rath <Nikol... at rath.org> wrote:
> So why does Python distinguish between e.g. the type 'int' and the
> class 'myclass'? Why can't I say that 'int' is a class and 'myclass'
> is a type?

I might be wrong here, but I think the point is that there is no
distinction. A class (lets call it SomeClass for this example) is an
object of type 'type', and an instance of a class is an object of type
'SomeClass'.

So int is a type, but if you have an int variable, its type is int.

Same for your classes.

This is, ignoring old style classes. Make sure all your classes
inherit from object to get new style classes.



More information about the Python-list mailing list