From b085b9be67f6d2c0fb5461ad9b5476298c4158bc Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 2 Mar 2017 18:47:39 +0100 Subject: [PATCH] network/library: fix Util.first to properly honor predicate --- library/network_connections.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/library/network_connections.py b/library/network_connections.py index 2e0b4a7..1504645 100755 --- a/library/network_connections.py +++ b/library/network_connections.py @@ -56,9 +56,8 @@ class Util: @staticmethod def first(iterable, default = None, pred = None): for v in iterable: - if pred is not None and pred(v): - continue - return v + if pred is None or pred(v): + return v return default @staticmethod