Why does test2() below print "True False"? I would expect "False False".
I expect test2() to change the global value EC to be False, so ec should also be False.
Why not?
Is there a straightforward way to get the "False False" behavior?
EC = True def test1(ec=EC): print(ec, EC) def test2(): global EC EC=False test1() https://stackoverflow.com/questions/65837698/python-globals-and-keyword-arguments January 22, 2021 at 08:27AM
没有评论:
发表评论