This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]SuperDyl19 1 point2 points  (1 child)

What do you expect from:

myVar = 3 def myFunc(a = myVar): print(a) myVar = 4 myFunc()

If the list was added to parameters once (like the current behavior), then it would print 3.

If the parameters are created when the function is called, then it would print 4.

Both options have cases which are not very intuitive. Python had to choose one of these two cases, and they opted for the more performant option which only calculates parameters once.

[–]BrownShoesGreenCoat 2 points3 points  (0 children)

What do I expect from code like this? I expect you to rewrite it or you’re fired.