-
-
Notifications
You must be signed in to change notification settings - Fork 46.5k
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!
* Create ipconversion.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update conversions/ipconversion.py * Update ipconversion.py * Rename ipconversion.py to ipv4_conversion.py * forward_propagation(32, 450_000) # Was 10_000_000 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com>
Describe your change:
Closes #9718
Closes #11013
Checklist: