UnboundMethodType and MethodType

Kirk McDonald mooquack at suad.org
Wed Feb 8 18:18:03 EST 2006


Scott David Daniels wrote:
> To elaborate on this, once 'id' is called, you drop the reference.
> This allows quite surprising things like:
>  >>> id(7**8) == id(8**7)
> True
>  >>> a, b = 7**8, 8**7
>  >>> id(a) == id(b) # this time there are other references to a and b
> False
> 
> If you wanted to test the original code for identity match:
>  >>> B.bar is B().bar
> False
> is the appropriate test (the 'is' test holds the identities through
> the comparison).
> 
> By the by, this is tricky stuff, nobody should expect to understand
> it thoroughly without both study and testing.
> 
> --Scott David Daniels
> scott.daniels at acm.org

You know what? That makes perfect sense. Thank you.

-Kirk McDonald



More information about the Python-list mailing list