Avoid use xx=[] for parameter in function
Use xx = [] for the parameter for function, 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: Icbade7dd4c7d231ae65fd4f8de673b484bab721c
This commit is contained in:
@@ -42,7 +42,9 @@ def quote_user_host(user, host):
|
|||||||
|
|
||||||
class Paginated(list):
|
class Paginated(list):
|
||||||
|
|
||||||
def __init__(self, items=[], next_marker=None, links=[]):
|
def __init__(self, items=None, next_marker=None, links=None):
|
||||||
|
items = items or []
|
||||||
|
links = links or []
|
||||||
super(Paginated, self).__init__(items)
|
super(Paginated, self).__init__(items)
|
||||||
self.next = next_marker
|
self.next = next_marker
|
||||||
self.links = links
|
self.links = links
|
||||||
|
@@ -399,10 +399,10 @@ class Paginated(object):
|
|||||||
next property you can use to get the next page of data.
|
next property you can use to get the next page of data.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, items=[], next_marker=None, links=[]):
|
def __init__(self, items=None, next_marker=None, links=None):
|
||||||
self.items = items
|
self.items = items or []
|
||||||
self.next = next_marker
|
self.next = next_marker
|
||||||
self.links = links
|
self.links = links or []
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(self.items)
|
return len(self.items)
|
||||||
|
@@ -272,7 +272,8 @@ class MgmtDatastoreVersions(base.ManagerWithFind):
|
|||||||
"version")
|
"version")
|
||||||
|
|
||||||
def create(self, name, datastore_name, datastore_manager, image,
|
def create(self, name, datastore_name, datastore_manager, image,
|
||||||
packages=[], active='true', default='false'):
|
packages=None, active='true', default='false'):
|
||||||
|
packages = packages or []
|
||||||
"""Create a new datastore version."""
|
"""Create a new datastore version."""
|
||||||
body = {"version": {
|
body = {"version": {
|
||||||
"name": name,
|
"name": name,
|
||||||
@@ -287,7 +288,8 @@ class MgmtDatastoreVersions(base.ManagerWithFind):
|
|||||||
return self._create("/mgmt/datastore-versions", body, None, True)
|
return self._create("/mgmt/datastore-versions", body, None, True)
|
||||||
|
|
||||||
def edit(self, datastore_version_id, datastore_manager=None, image=None,
|
def edit(self, datastore_version_id, datastore_manager=None, image=None,
|
||||||
packages=[], active=None, default=None):
|
packages=None, active=None, default=None):
|
||||||
|
packages = packages or []
|
||||||
"""Update a datastore-version."""
|
"""Update a datastore-version."""
|
||||||
body = {}
|
body = {}
|
||||||
if datastore_manager is not None:
|
if datastore_manager is not None:
|
||||||
|
Reference in New Issue
Block a user