Don't parse it. Just ask.
import socket try: socket.inet_aton(addr) # legal except socket.error: # Not legal
548k questions
547k answers
4 comments
86.3k users