Re: Difference between type and class
- From: Nikolaus Rath <Nikolaus@xxxxxxxx>
- Date: Thu, 31 Jul 2008 14:30:19 +0200
oj <ojeeves@xxxxxxxxx> writes:
On Jul 31, 11:37 am, Nikolaus Rath <Nikol...@xxxxxxxx> 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'.
But there seems to be a distinction:
.... passclass int_class(object):
....
<class '__main__.int_class'>int_class
<type 'int'>int
why doesn't this print
.... passclass int_class(object):
....
<type '__main__.int_class'>int_class
<type 'int'>int
or
.... passclass int_class(object):
....
<class '__main__.int_class'>int_class
<class 'int'>int
If there is no distinction, how does the Python interpreter know when
to print 'class' and when to print 'type'?
Best,
-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: Maric Michaud
- Re: Difference between type and class
- References:
- Difference between type and class
- From: Nikolaus Rath
- Re: Difference between type and class
- From: oj
- Difference between type and class
- Prev by Date: Re: SVN access with pysvn under Cygwin (Installation problems)
- Next by Date: Re: working pylint anyone?
- Previous by thread: Re: Difference between type and class
- Next by thread: Re: Difference between type and class
- Index(es):
Relevant Pages
|