I have the following function declaration:def set_data(obj=None, name='delp', type=None):Is there a python shortcut, where type is equal with 'name' value(default r passed) if is None ? 解决方案 The usual idiom is:def set_data(obj=None, name='delp', type=None): if type is None: type = name(But don't actually use type as a variable name, it'll mask the built in function as described here: Is it safe to use the python word "type" in my code?) 这篇关于变量默认值的 Python 快捷方式是另一个变量值,如果它是 None的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-30 06:53