ip address - Determine if Host is Domain Name or IP in Python -
is there function in python determines if hostname domain name or ip(v4) address?
note, domain name may like: alex.foo.bar.com or (i think valid): 1.2.3.com.
i'd use ipy test if string ip address, , if isn't - assume it's domain name. e.g.:
from ipy import ip def isip(str): try: ip(str) except valueerror: return false return true
Comments
Post a Comment