Don't parse it. Just ask.
import socket try: socket.inet_aton(addr) # legal except socket.error: # Not legal
2.1m questions
2.1m answers
60 comments
57.0k users