Purpose of calling function without brackets python
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Consider the following: class objectTest (): def __init__ ( self , a ): self . value = a def get_value ( self ): return self . value class execute (): def __init__ ( self ): a = objectTest ( 1 ) b = objectTest ( 1 ) print ( a == b ) print ( a . get_value () == b . get_value ) print ( a . get_value () == b . get_value ()) print ( a . get_value == b . get_value ) if __name__ == '__main__' : execute = execute (); This code return >>> False False True False Given that get_value is a function, I would expect the execution to stop and