Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Validate an IPv4 address.
def is_ip(value):
"""IP simple validation in response to blog post http://goo.gl/L9cKh"""
try:
bytes = [int(e) for e in value.split('.') if 0 <= int(e) <= 255)]
except ValueError:
return False
return len(bytes) == 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment