Created
September 5, 2011 21:46
-
-
Save danielgoncalves/1195995 to your computer and use it in GitHub Desktop.
Validate an IPv4 address.
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
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