In Python, what determines the order while iterating through kwargs?

前端 未结 6 1300
悲&欢浪女
悲&欢浪女 2020-12-03 17:45

In python, I wrote this function to teach myself how **kwargs works in Python:

def fxn(a1, **kwargs):
    print a1
    for k in kwargs:
                 


        
6条回答
  •  爱一瞬间的悲伤
    2020-12-03 18:09

    Since kwargs is a Python dictionary, which is implemented as a hash table, its ordering is not preserved and is effectively random.

    Actually, as a fix to a recent security issue in many programming languages, in the future the order may even change between invocations of your program (invocations of the Python interpreter).

提交回复
热议问题