How to check arguments of the function?

前端 未结 3 1884
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-25 00:23

I have function defined this way:

def f1 (a, b, c = None, d = None):
    .....

How do I check that a, b are not equal

3条回答
  •  春和景丽
    2021-01-25 00:55

    for key, value in locals().items():
        if value is not None:
            check_attribute(key, value)
    

    Though as others have said already, you can just check the arguments directly by name.

提交回复
热议问题