On Apr 1, 6:10 pm, Steve Holden <st...@holdenweb.com> wrote:
> Chris Rebert wrote:
> > Personally, I hate such abuse with a passion; I think a global
> > variable is clearest.
>
> But the real problem is that the OP is insisting on using purely
> procedural Python when the problem is screaming for an object-oriented
> answer.
>
> If the function were instead a method then the instance namespace would
> be the logical place to store the required data.

In some situations I will use either the default parameter
initialization Chris mentioned, or the closure mechanism that the OP
presented, but only on code that I am optimizing for speed (local
variable lookups, even in nested functions, being much faster than
global or instance lookups).  If it doesn't need to go fast, globals
or instance variables are the way to go.

Pat
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to