bizarre id() results
smcg4191zz at friizz.RimoovAllZZs.com
Thu Dec 15 22:19:15 CET 2005
The following was cut and pasted exactly (except for the
# lines which I added after the fact) from an interactive python
session in a Window 2000 cmd.exe window.
Can somebody please explain to me what the heck is
Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> class A:
... def m1(self): print "m1"
... def m2(self): print "m2"
>>> a = A()
# ok, both methods work and give the expected results
# so i presume they are different methods.
# Huh? They seem to be the same.
>>> a.m1 is a.m2
# But not the same...
<bound method A.m1 of <__main__.A instance at 0x00923B98>>
<bound method A.m2 of <__main__.A instance at 0x00923B98>>
# Let's look at them in hex...
# Now they are different. 0x8c6d28->9202984, 0x8e7b48->9337672
# Now they are both equal to the second one.
# in hex too.
<built-in function id>
<built-in function hex>
# just double checking!
Why??? This is so bizarre I'm sure I am doing something
More information about the Python-list