1
0

Do not use mutables as default values!

This blog article explains why (just an example, many other articles
discuss this ad nauseam):
http://pythonconquerstheuniverse.wordpress.com/2012/02/15/mutable-default-arguments/
This commit is contained in:
Chris Glass
2014-06-25 17:43:45 +02:00
parent fff3ed9b77
commit 8997c760a2
4 changed files with 12 additions and 7 deletions

View File

@@ -241,7 +241,9 @@ class Blockchain(threading.Thread):
return h
def get_target(self, index, chain=[]):
def get_target(self, index, chain=None):
if chain is None:
chain = [] # Do not use mutables as default values!
max_target = 0x00000000FFFF0000000000000000000000000000000000000000000000000000
if index == 0: return 0x1d00ffff, max_target