How Does This Static Variable Work?
mr.cerutti at gmail.com
Fri Jan 4 17:34:26 CET 2008
On Jan 4, 2008 10:17 AM, Victor Subervi <victorsubervi at gmail.com> wrote:
> I read this example somewhere, but I don't understand it <:-) Can someone
> please explain how static variables work? Or recommend a good how-to?
> import random
> def randomwalk_static(last=): # init the "static" var(s)
> rand = random.random() # init a candidate value
Simulating C's static local variables is the (in)famous application for this
case of optimization in Python's design.
Consult the following entry in the Python General Programming FAQ for
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list