Normal arguments vs. keyword arguments

后端 未结 10 843
一个人的身影
一个人的身影 2020-11-22 02:35

How are \"keyword arguments\" different from regular arguments? Can\'t all arguments be passed as name=value instead of using positional syntax?

10条回答
  •  春和景丽
    2020-11-22 02:59

    Using keyword arguments is the same thing as normal arguments except order doesn't matter. For example the two functions calls below are the same:

    def foo(bar, baz):
        pass
    
    foo(1, 2)
    foo(baz=2, bar=1)
    

提交回复
热议问题