3 points · by kirubakaran · 18y ago · 1 comment
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.