根据以下代码片段:
import time
def custom_time():
return time.time()
class TimeWrapper:
builtin_time = time.time
def print_builtin(self):
print(self.builtin_time())
custom_time = custom_time
def print_custom(self):
print(self.custom_time())
wrapper = TimeWrapper()
wrapper.print_builtin()
# 1660163626.7973292
wrapper.print_custom()
# TypeError: custom_time() takes 0 positional arguments but 1 was given
time.time(wrapper)
# TypeError: time.time() takes no arguments (1 given)
custom_time(wrapper)
# TypeError: custom_time() takes 0 positional arguments but 1 was given
我不明白为什么wrapper.print_builtin()
是有效的.
难道它不应该等同于time.time(wrapper)
吗?
从C implementation开始的unused
论点有什么联系吗?
如果不是这样,我仍然对这个未使用的变量感兴趣.