static variables?
Padraig Brady
Padraig at Linux.ie
Tue Nov 19 10:29:06 EST 2002
Josh wrote:
> Hi guys,
>
> I am a python newbie, and I am sure there is an easy answer but, Is there
> any equivalent to C's static variables in Python? If not, how can you have
> variables inside a function, that 'remember' their values between function
> calls?
>
> Josh
For functions you could set attributes of the function
as static variables? like:
def func():
func.name="value"
Then the attribute will be stored with the function
and so is as long lived as the function
Pádraig.
More information about the Python-list
mailing list