4
說我有下面的代碼:我應該如何評論部分Python函數?
def func(x, y = 1, z = 2):
""" A comment about this function """
return x + y + z
another_func = partial(func, z = 4)
什麼是記錄了another_func功能的正確或Python的方式?
說我有下面的代碼:我應該如何評論部分Python函數?
def func(x, y = 1, z = 2):
""" A comment about this function """
return x + y + z
another_func = partial(func, z = 4)
什麼是記錄了another_func功能的正確或Python的方式?
參見http://docs.python.org/library/functools.html#functools.partial
喜歡該部分()描述:
another_func.__doc__ = "My documentation"
[證明在文檔中最正確的方法](http://docs.python.org/library/functools。 html#functools.partial) – SilentGhost 2010-10-20 15:19:41
user368186,我的答案是否適合你?如果是這樣,你可以選擇它是正確的? – kanaka 2010-10-21 13:00:37
對不起,在我的延遲響應。忙碌的一天。這真是太好了,謝謝你。 – 2010-10-21 16:09:15