Re: Difference between type and class
- From: oj <ojeeves@xxxxxxxxx>
- Date: Thu, 31 Jul 2008 04:29:45 -0700 (PDT)
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'.
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.
.
- Follow-Ups:
- Re: Difference between type and class
- From: Nikolaus Rath
- Re: Difference between type and class
- References:
- Difference between type and class
- From: Nikolaus Rath
- Difference between type and class
- Prev by Date: Re: Terminate a python script from linux shell / bash script
- Next by Date: Re: How smart is the Python interpreter?
- Previous by thread: Difference between type and class
- Next by thread: Re: Difference between type and class
- Index(es):
Relevant Pages
|