This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients lgj1993, steven.daprano
Date 2019-03-02.02:36:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1551494208.65.0.716214249409.issue36163@roundup.psfhosted.org>
In-reply-to
Content
The ``is`` operator returns False because the two objects are different objects.

Methods are descriptors, and whenever you access an instance method, you get a brand-new method object. This is described in the documentation for descriptors:

https://docs.python.org/3/howto/descriptor.html#functions-and-methods

The last two tests in your example both call id(a.a), which returns the same ID number for precisely the same reason as we explained in your previous bug report #36156. Since the two "a.a" method objects don't exist at the same time, the interpreter is permitted to re-use the same ID number for them.

P.S. remember in the previous bug report you raised, I asked you to use less awkward and confusing names? "a.a" is a terrible name, even for a simple example like this. It makes it hard to talk about what is going on when "a" is an instance and also a method.
History
Date User Action Args
2019-03-02 02:36:48steven.dapranosetrecipients: + steven.daprano, lgj1993
2019-03-02 02:36:48steven.dapranosetmessageid: <1551494208.65.0.716214249409.issue36163@roundup.psfhosted.org>
2019-03-02 02:36:48steven.dapranolinkissue36163 messages
2019-03-02 02:36:48steven.dapranocreate