我听说Liskov替换原则(LSP)是面向对象设计的基本原则.它是什么以及它的使用例子是什么?
oop liskov-substitution-principle definition design-principles solid-principles
为字典参数添加docstring的推荐方法是什么?我可以在这里看到多行doc-string示例.
我需要在docstring中记录函数的输入参数.如果它是一个简单的变量,我可以使用类似的东西:
def func2(a=x, b = y):
""" fun2 takes two integers
Keyword arguments:
a -- refers to age (default 18)
b -- refers to experience (default 0)
"""
Run Code Online (Sandbox Code Playgroud)
如果我们dict作为输入参数传递给函数:
def func3(**kwargs):
""" takes dictionary as input
<Here how to explain them - Is it like?>
kwargs['key1'] -- takes value1
<or simply>
key1 -- takes value1
"""
Run Code Online (Sandbox Code Playgroud)