Using default arguments before positional arguments

后端 未结 3 2207
长情又很酷
长情又很酷 2021-02-13 15:18

I am learning to use positional arguments in python and also trying to see how they work when mixed up with default arguments:-

def withPositionalArgs(ae=9,*args         


        
3条回答
  •  孤城傲影
    2021-02-13 15:38

    Python3 has relaxed ordering.

    Now you can do something like:

    def withPositionalArgs(*args, ae=9):
        print('ae=', ae)
        print('args =', args)
    a=1
    b=2
    c=[10, 20]
    withPositionalArgs(a, b, c, ae=7)
    

提交回复
热议问题