Created
June 25, 2017 12:50
-
-
Save hughrawlinson/17210245983a482955fdaf3e8d309ab3 to your computer and use it in GitHub Desktop.
π¨ extremely unpythonic python alert π¨
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def is_valid_IP(strng): | |
t = re.compile("^\d+$") | |
try: | |
return (lambda m: len(m) is 4 and reduce(lambda acc, el: acc and el, [True] + m))(map(lambda x: (lambda x: x < 256 and x >= 0)(int(x)) and (x[0] is not '0' if len(x) > 1 else True) and t.match(x) is not None, strng.split('.'))) | |
except Exception: | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment