Op 27/04/20 om 18:39 schreef Bob van der Poel:
Thanks Chris!
At least my code isn't (quite!) as bad as the xkcd example :)
Guess my "concern" is using the initialized array in the function:
def myfunct(a, b, c=array[0,1,2,3] )
always feels like an abuse.
Has anyone seriously considered implementing a true static variable in a
function? Is there a PEP?
You can emulate a static variable is with a closure.
def make_parseStack():
depth = 0
def parseStack(inc):
nonlocal depth
if depth > 50:
... report error and die nicely
depth += inc
return parseStack
parseStack = make_parseStack()
--
Antoon Pardon.
--
https://mail.python.org/mailman/listinfo/python-list