mcgrew, I just remembered a Python behavior I learned about in college that could have bitten me:
>>> def addbork(borklist=[]):
... borklist.append('bork')
... return borklist
...
>>> addbork()
['bork']
>>> addbork()
['bork', 'bork']This happens because the default argument is instantiated when the function is defined rather than when it is called, so any changes to the object persist on subsequent calls. #python #programming
Add comment