Skip to content

Instantly share code, notes, and snippets.

@hughrawlinson
Created June 25, 2017 12:50
Show Gist options
  • Save hughrawlinson/17210245983a482955fdaf3e8d309ab3 to your computer and use it in GitHub Desktop.
Save hughrawlinson/17210245983a482955fdaf3e8d309ab3 to your computer and use it in GitHub Desktop.
🚨 extremely unpythonic python alert 🚨
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