Can I use the variable name “type” as function argument in Python?

前端 未结 5 1504
别那么骄傲
别那么骄傲 2020-12-07 00:44

Can I use type as a name for a python function argument?

def fun(name, type):
    ....
5条回答
  •  青春惊慌失措
    2020-12-07 01:11

    You can use any non-keyword as an identifier (as long as it's a valid identifier of course). type is not a keyword, but using it will shadow the type built-in.

提交回复
热议问题