We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Instead of doing a regex for IP(v4) addresses, you might consider using native Python functionality such as:
https://docs.python.org/3/library/socket.html#socket.inet_pton https://docs.python.org/2/library/socket.html#socket.inet_pton
which would be IP version agnostic and would allow a check like:
def check_ipv6(n): try: socket.inet_pton(socket.AF_INET6, n) return True except socket.error: return False
Or in v3 only there is the native ipaddress module:
https://docs.python.org/3/library/ipaddress.html
(see https://docs.python.org/3/howto/ipaddress.html#ipaddress-howto)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Instead of doing a regex for IP(v4) addresses, you might consider using
native Python functionality such as:
https://docs.python.org/3/library/socket.html#socket.inet_pton
https://docs.python.org/2/library/socket.html#socket.inet_pton
which would be IP version agnostic and would allow a check like:
def check_ipv6(n):
try:
socket.inet_pton(socket.AF_INET6, n)
return True
except socket.error:
return False
Or in v3 only there is the native ipaddress module:
https://docs.python.org/3/library/ipaddress.html
(see https://docs.python.org/3/howto/ipaddress.html#ipaddress-howto)
The text was updated successfully, but these errors were encountered: