[Tutor] why i < j is True, j < k is False

Lion Chen chnlion79 at gmail.com
Fri May 4 16:12:38 CEST 2012


> On Fri, May 4, 2012 at 9:29 AM, Lion Chen<chnlion79 at gmail.com>  wrote:
>> Hi, All,
>> here are the codes:
>>
>> class a:
>> pass
>>
>>
>> i = a ()
>> j = a ()
>> k = a ()
>>
>> i<  j returns True
>>
>> j<  k returns False
>>
>> why?
>>
>> Lion Chen
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
> Did you look at what I, j, and k are?  They are names of objects.
> When I ran your code my inequalities were different.
> What you are seeing is likely some comparison of the location of the
> objects over which you have no control
>>>> i = a()
>>>> j = a()
>>>> k = a()
>>>> i<  j
> False
>>>> j<  k
> True
>>>> i
> <__main__.a instance at 0xb76d0a2c>
>>>> j
> <__main__.a instance at 0xb76d096c>
>>>> k
> <__main__.a instance at 0xb76d09ec>
> but why have i got the same results every time i run the codes?
even when i restart the python interpreter,  seems like i, j, k have the 
fixed values.
>
>



More information about the Tutor mailing list