-
-
Notifications
You must be signed in to change notification settings - Fork 44.3k
New issue
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
Create ipv4_conversion.py #11008
Create ipv4_conversion.py #11008
Conversation
for more information, see https://pre-commit.ci
conversions/ipconversion.py
Outdated
'10.0.0.255' | ||
""" | ||
|
||
if not (0 <= decimal_ip <= 4294967295): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would not catch 10.0.0.256 which is not a valid IP.
conversions/ipconversion.py
Outdated
for part in ip_parts: | ||
decimal_ip = (decimal_ip << 8) + int(part) | ||
|
||
return decimal_ip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def alt_ip_to_decimal(ip_address: str) -> int:
return int("0x" + "".join(f"{int(i):02x}" for i in ip_address.split(".")), 16)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one!
Describe your change:
Closes #9718
Closes #11013
Checklist: