sameness/identity

Duncan Booth duncan at NOSPAMrcp.co.uk
Tue Oct 2 04:07:19 EDT 2001


weeks at vitus.scs.agilent.com (Greg Weeks) wrote in 
news:1001876090.367103 at cswreg.cos.agilent.com:

> Consider:
> 
>     x = 6.02
>     y = 6.02
> 
> Are x and y identical?  They are identical as *numbers* (which I'll call
> conceptual identity) but not as Python *implentations* of numbers (since
> id(x) != id(y)).  

Just to correct you on one thing. If you put your two assignments to x and 
y into a module or a script then you will find id(x)==id(y). It is only if 
you type the assignments into interactive mode (or different modules, or 
the results of calculations), that they will be different.

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?



More information about the Python-list mailing list