using "private" parameters as static storage?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Thu Nov 13 22:38:26 EST 2008


On Thu, 13 Nov 2008 13:35:21 -0500, 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.
>> 
> This is a pretty bizarre requirement, IMHO. The normal place to keep
> such information is either class variables or instance variables.

*jaw drops*

You know, there were one or two programs written before the invention of 
object-oriented programming techniques. Some of them required persistent 
storage between function calls, and global variables have obvious 
disadvantages. That's why the C language uses static variables.

http://c.ittoolbox.com/documents/popular-q-and-a/difference-between-
static-global-variable-1596

http://en.wikipedia.org/wiki/Static_variable


-- 
Steven



More information about the Python-list mailing list