using "private" parameters as static storage?

Ben Finney bignose+hates-spam at
Fri Nov 14 01:09:29 CET 2008

Joe Strout <joe at> writes:

> 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

This is precisely what classes are for: allowing functionality and
state to exist in a single object.

> but not visible outside the method.

Bind the state to a name with a single leading underscore (‘_foo’),
which is the convention for “not part of the public interface”.
Don't look for hard access restrictions, though, because they don't
really exist in Python.

 \     “I hope that after I die, people will say of me: ‘That guy sure |
  `\                            owed me a lot of money’.” —Jack Handey |
_o__)                                                                  |
Ben Finney

More information about the Python-list mailing list