Skip to content

Persistent variable in function

Ariel Balter edited this page Apr 1, 2016 · 1 revision

http://stackoverflow.com/a/16214510/188963

def foo():
    try:
        foo.counter += 1
    except AttributeError:
        foo.counter = 1
Clone this wiki locally