Hi;
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=[1]): # init the "static" var(s)
rand = random.random() # init a candidate value
if last[0] < 0.1: # threshhold terminator
return None # end-of-stream flag
while abs(last[0]-rand) < 0.4: # look for usable candidate
print '*', # display the rejection
rand = random.random() # new candidate
last[0] = rand # update the "static" var
return rand
TIA,
Victor
--
http://mail.python.org/mailman/listinfo/python-list