Very strange behavior of operator 'is' with methods

前端 未结 2 930
情歌与酒
情歌与酒 2021-02-01 12:51

Why is the first result False, should it not be True?

>>> from collections import OrderedDict
>>> OrderedDict.__repr_         


        
2条回答
  •  醉酒成梦
    2021-02-01 13:48

    The two OrderedDict.__repr__ are not bound to the same object. If you try:

     OrderedDict.__repr__ == OrderedDict.__repr__
    

    you'll see that they have the same value.

提交回复
热议问题