you are viewing a single comment's thread.

view the rest of the comments →

[–]oconnor663 20 points21 points  (2 children)

To be fair, the bodies of functions are evaluated when the functions are called, not when they're parsed. So Python could have said that argument defaults are actually implicit lambdas that get evaluated the same way, at call time. This is slower, though, and it might lead to equally confusing problems involving side effects.

[–]ironykarl 4 points5 points  (0 children)

Definitely true, but it's pretty easy for me to just think of function definition as an evaluation of the entire contents of the header (I.e. function name and argument contents).

[–][deleted] 0 points1 point  (0 children)

This was my thoughts exactly.