Function to execute only once

PyPK superprad at gmail.com
Fri Oct 14 15:11:58 EDT 2005


Hi if I have a function called
tmp=0
def execute():
    tmp = tmp+1
    return tmp

also I have
def func1():
    execute()
    ....
and
def func2():
    execute()
    ....

now I want execute() function to get executed only once. That is the
first time it is accessed.
so taht when funcc2 access the execute fn it should have same values as
when it is called from func1.




More information about the Python-list mailing list