-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
gh-128810: Added .shorthand property to IPv4Network and IPv6Network in the ipaddress module #128811
base: main
Are you sure you want to change the base?
Conversation
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
@@ -0,0 +1 @@ | |||
Added a .shorthand function to IPv4Network and IPv6Network's in the ipaddress module to be able to display a prefix such as 1.2.0.0/16 as it's shorthand version (often used by network operators) as 1.2/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.
Added a .shorthand function to IPv4Network and IPv6Network's in the ipaddress module to be able to display a prefix such as 1.2.0.0/16 as it's shorthand version (often used by network operators) as 1.2/16. | |
Add the :attr:`!shorthand` property to :class:`~ipaddress.IPv4Network` and :class:`~ipaddress.IPv6Network` in the :mod:`ipaddress` module to display a prefix such as ``1.2.0.0/16`` as its shorthand version (often used by network operators), like ``1.2/16``. |
Edit
More tags, see https://devguide.python.org/documentation/markup/
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.
We're still discussing approaches in the issue, and if we want to actually go for this (the RFC specifying this is a best practice rather than a standard).
That, and I don't like shorthand
being the name, because that's not really what it's called universally. Something like cidr
or cidr_shorthand
would be more correct.
I will update the PR shortly, still discussing the desired behavior as ZeroIntensity mentioned. Thank you all for your feedback! |
Pretty straightforward. Addresses gh-128810. Added a .shorthand property to all ip_networks for ease-of-use, since this is how they are commonly written by network operators. This way for a prefix 1.2.0.0/16 the shorthand of 1.2/16 can easily be accessed.
#128810