I've been teaching myself Python for about 3 weeks.
Does Python have something equivalent to a static variable in C, i.e., a variable local to a function that will retain its value across calls? The closest thing I've been able to come up with is a global variable that's modified within the function, e.g.
Is there a better way to do this? Thanks.
Does Python have something equivalent to a static variable in C, i.e., a variable local to a function that will retain its value across calls? The closest thing I've been able to come up with is a global variable that's modified within the function, e.g.
Code:
prtlines_first=True # initialized at module level
def prtlines(line):
global prtlines_first
if prtlines_first:
# do something first time function is called
else:
prtlines_first=False
# rest of function