Difference between type and class
- From: Nikolaus Rath <Nikolaus@xxxxxxxx>
- Date: Thu, 31 Jul 2008 12:37:13 +0200
Hello,
Can someone explain to me the difference between a type and a class?
After reading http://www.cafepy.com/article/python_types_and_objects/
it seems to me that classes and types are actually the same thing:
- both are instances of a metaclass, and the same metaclass ('type')
can instantiate both classes and types.
- both can be instantiated and yield an "ordinary" object
- I can even inherit from a type and get a class
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 hope I have managed to get across the point of my confusion...
Thanks in advance,
-Nikolaus
--
»It is not worth an intelligent man's time to be in the majority.
By definition, there are already enough people to do that.«
-J.H. Hardy
PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C
.
- Follow-Ups:
- Re: Difference between type and class
- From: Thomas Troeger
- Re: Difference between type and class
- From: oj
- Re: Difference between type and class
- Prev by Date: Re: Optimizing size of very large dictionaries
- Next by Date: Re: Is it possible to consume UTF8 XML documents using xml.dom.pulldom?
- Previous by thread: working pylint anyone?
- Next by thread: Re: Difference between type and class
- Index(es):
Relevant Pages
|