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:
7
electrum
7
electrum
@@ -103,16 +103,15 @@ def print_help_cb(self, opt, value, parser):
|
||||
print_help(parser)
|
||||
|
||||
|
||||
def run_command(cmd, password=None, args=[]):
|
||||
import socket
|
||||
def run_command(cmd, password=None, args=None):
|
||||
if args is None:
|
||||
args = [] # Do not use mutables as default values!
|
||||
if cmd.requires_network and not options.offline:
|
||||
network = NetworkProxy(config)
|
||||
if not network.start(start_daemon= (True if cmd.name!='daemon' else False)):
|
||||
print "Daemon not running"
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
||||
if wallet:
|
||||
wallet.start_threads(network)
|
||||
wallet.update()
|
||||
|
||||
Reference in New Issue
Block a user