Set the initial value to None

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 None

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

Change-Id: I9f61be1ba38901959d5c9201d41e2ce5911505e5
This commit is contained in:
lilintan 2016-09-25 10:48:24 +08:00
parent 61da81dbf9
commit f6e549f9be
1 changed files with 3 additions and 1 deletions

View File

@ -33,7 +33,9 @@ from six.moves.urllib import parse
from kingbirdclient.openstack.common.apiclient import client
def assert_has_keys(dct, required=[], optional=[]):
def assert_has_keys(dct, required=None, optional=None):
required = required or []
optional = optional or []
for k in required:
try:
assert k in dct