Don't use mutable defaults as args for methods

This commit is contained in:
Matt Martz 2016-11-11 10:00:24 -06:00
parent 6685d91729
commit c512684ffa
1 changed files with 5 additions and 2 deletions

View File

@ -779,10 +779,13 @@ class Speedtest(object):
return self.config return self.config
def get_servers(self, servers=[]): def get_servers(self, servers=None):
"""Retrieve a the list of speedtest.net servers, optionally filtered """Retrieve a the list of speedtest.net servers, optionally filtered
to servers matching those specified in the ``servers`` argument to servers matching those specified in the ``servers`` argument
""" """
if servers is None:
servers = []
self.servers.clear() self.servers.clear()
for i, s in enumerate(servers): for i, s in enumerate(servers):
@ -951,7 +954,7 @@ class Speedtest(object):
printer(self.closest, debug=True) printer(self.closest, debug=True)
return self.closest return self.closest
def get_best_server(self, servers=[]): def get_best_server(self, servers=None):
"""Perform a speedtest.net "ping" to determine which speedtest.net """Perform a speedtest.net "ping" to determine which speedtest.net
server has the lowest latency server has the lowest latency
""" """