What is the best way in python to write docstrings for lambda functions?
问题 I usually comment my functions using multi-line docstrings with """, as mentioned in : https://www.python.org/dev/peps/pep-0257/ def func1(x): """ This function does ... """ ... But what is the best way to comment a lambda function ? I hesitate between : # This function does ... func2 = lambda x: ... or : func2 = lambda x: ... """ This function does ... """ or else ? 回答1: tbh, even assigning a lambda to a variable seems unpythonic to me. if it needs a name, define it as a regular function.