using "private" parameters as static storage?

Steve Holden steve at holdenweb.com
Thu Nov 13 14:45:19 EST 2008


Steve Holden wrote:
> Joe Strout wrote:
>> One thing I miss as I move from REALbasic to Python is the ability to
>> have static storage within a method -- i.e. storage that is persistent
>> between calls, but not visible outside the method.  I frequently use
>> this for such things as caching, or for keeping track of how many
>> objects a factory function has created, and so on.
>>
[...]
> I think you'd be much better off creating an instance of a class and
> using that.
> 
Or, as JP suggested, a generator function. This allows you to maintain
whatever state you need in the function's local namespace.

regards
 Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list