Python3 common patterns

Modify some codes in order to make them meet
the Python3 common pattern.
In this patch,I replace filter(lambda obj: test(obj),data)
with[obj for obj in data if test(obj)]

Change-Id: I68e76f91dc31aa0e00124c1eb76a0a1f0178cc44
This commit is contained in:
Ji zhaoxuan 2016-12-29 14:49:06 +08:00 committed by Jizhaoxuan
parent 1d483ae0c7
commit 6805390a1d
2 changed files with 2 additions and 2 deletions

View File

@ -41,7 +41,7 @@ def find_items(items, **props):
return True
filtered = list(filter(lambda item: _matches(item, **props), items))
filtered = list([item for item in items if _matches(item, **props)])
if len(filtered) == 1:
return filtered[0]

View File

@ -79,7 +79,7 @@ class SSHActionsTestsV2(base.TestCaseAdvanced):
'floating_ips'
)
free_ips = list(
filter(lambda fl_ip: fl_ip['instance_id'] is None, all_ips)
[fl_ip for fl_ip in all_ips if fl_ip['instance_id'] is None]
)
if free_ips: