【发布时间】:2017-06-30 02:36:51
【问题描述】:
在许多代码中,我看到带有函数的类,它们只是使用了pass 短语并对它们进行了一些评论。
喜欢这个来自 python 的原生内置函数:
def copyright(*args, **kwargs): # real signature unknown
"""
interactive prompt objects for printing the license text, a list of
contributors and the copyright notice.
"""
pass
我知道 pass 什么都不做,它是一种冷漠和null 的短语,但是程序员为什么要使用这样的函数呢?
还有一些带有return ""的功能,比如:
def bin(number): # real signature unknown; restored from __doc__
"""
bin(number) -> string
Return the binary representation of an integer.
>>> bin(2796202)
'0b1010101010101010101010'
"""
return ""
为什么程序员使用这些东西?
【问题讨论】:
标签: python python-3.x null python-2.x