[Tutor] integers are also objects?

karthik Guru karthikg@aztec.soft.net
Mon, 3 Dec 2001 14:39:42 +0530


thanks a lot for the information.
since integer are objects, do integers also inherit from some class?? rather
are integers instance of some class?
Has the __eq__() been overridden for that class to return 1 if the content
happens to be the same. what is that class?

thanks for your patience,
karthik.



-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Andrei Kulakov
Sent: Monday, December 03, 2001 1:18 PM
To: tutor@python.org
Subject: Re: [Tutor] integers are also objects?


On Mon, Dec 03, 2001 at 11:19:03AM +0530, karthik Guru wrote:
> hi all!,
>
> I'm having a very basic python doubt.
>
> Are integers objects in python?
>
> d:\>python
> Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
> Type "copyright", "credits" or "license" for more information.
> >>> i = 10
> >>> a = 5+5
> >>> id(a)
> 8136016
> >>> id(i)
> 8136016
>
> In both cases, i and a, the id of the objects happened to be same
though i
> created 2 different integer objects.
> so (i == a) obviously works.
>
> So my question is that does "==" work on contents in case of integers
or
it
> works only on
> references and python makes sure that integer references with same
content
> point to the
> same location, the way it works for strings.
>
> thanks in advance,
> karthik.

0 to 99 are pre-created integer objects, for speed. whenever you have a
variable that is 0 to 99, one of these objects gets assigned to it..

>
>
>
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

--
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor