Avoid use xx=[] for parameter initial value

Use xx = [] for the parameter initial value, this parameter will
only be initialized at the first call, this is should be avoided.
Better choice is to set the initial value to None, then the initialization
time use xx= xx or []

more information:http://effbot.org/zone/default-values.htm

Change-Id: Ia89b9741731c07d8bf08691a1c6544742625cad6
This commit is contained in:
jiansong 2016-09-24 19:24:33 -07:00 committed by jian.song
parent c22d37b51c
commit 12be3210eb
1 changed files with 3 additions and 1 deletions

View File

@ -24,7 +24,9 @@ def get_version_map():
}
def assert_has_keys(dict, required=[], optional=[]):
def assert_has_keys(dict, required=None, optional=None):
required = required or []
optional = optional or []
keys = dict.keys()
for k in required:
try: