by makecheck · 18y ago · 0 comments
Python always evaluates the default values of arguments; this is done at parsing time. So if you define a function f(a=x()) and never call f(), there will still be a call to x().
The first work-around mentioned in the article (to assign None as a value, and test for None before setting a default), is the approach that I prefer when the default value is non-trivial.
No comments yet.