Skip to content

billsix/staticlocal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

staticlocal

Python implementation of static local variables.

Static local variables are variables local to a function, which upon first application, assign a value to the variable. The value bound by the variable persists after the function application completes, so the state is preserved across muliple applications of the function.

>>> import staticlocal
>>> def foo():
...     x = 1
...     staticlocal.var(fn=foo, y=3,z=6)
...     x = x + 1
...     foo.y = foo.y+1
...     foo.z = foo.z+1
...     return x, foo.y, foo.z
...
>>> foo()
(2, 4, 7)
>>> foo()
(2, 5, 8)
>>> foo()
(2, 6, 9)
>>> foo()
(2, 7, 10)

About

Static local variables for python functions

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages