From a66bb6b0c5d4c2c51b2ac0a93000309cf910c7d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Fri, 26 Sep 2014 23:41:46 +0000 Subject: [PATCH] simplify --- rfc3986/uri.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/rfc3986/uri.py b/rfc3986/uri.py index 818512e..6458fb9 100644 --- a/rfc3986/uri.py +++ b/rfc3986/uri.py @@ -370,13 +370,4 @@ class URIReference(namedtuple('URIReference', URI_COMPONENTS)): def valid_ipv4_host_address(host): # If the host exists, and it might be IPv4, check each byte in the # address. - for byte in host.split('.'): - byte_val = int(byte, base=10) - if byte_val < 0 or byte_val > 255: - # If the value is not in the correct range it is invalid. - # Return False immediately - return False - - # If we haven't returned yet, the host existed, and appeared to be - # IPv4, then it should be a valid IPv4 - return True + return all([0 <= int(byte, base=10) <= 255 for byte in host.split('.')])