Need help with Python scoping rules
greg at cosc.canterbury.ac.nz
Thu Aug 27 12:50:41 CEST 2009
> No, the fact() function here represents an internal "helper"
> function. It is meant to be called only once to help initialize
> a class variable that would be inconvenient to initialize otherwise;
> this helper function is not meant to be called from outside the
> class statement.
That, to me, is an excellent indication that the function
does *not* belong inside the class!
The only things that belong inside the class are things
that users of the class will need to use, or that instances
of the class will need to do their job.
Your helper function belongs outside the class, in the
module where the class is defined.
More information about the Python-list