a == b is false, but id(a) == id(b) is true?

前端 未结 3 1024
眼角桃花
眼角桃花 2021-01-04 07:33

Ran into the following:

>>> class A:
...     def __str__(self):
...             return \"some A()\"
... 
>>> class B(A):
...     def __str_         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-04 08:17

    The following works:

    >>> id(A.__str__.im_func) == id(A.__str__.im_func)
    True
    >>> id(B.__str__.im_func) == id(A.__str__.im_func)
    False
    

提交回复
热议问题