Skip to content
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

ipaddress: Add optional prefixlen argument to ip_interface and ip_network #67151

Closed
GaryvanderMerwe mannequin opened this issue Nov 28, 2014 · 3 comments
Closed

ipaddress: Add optional prefixlen argument to ip_interface and ip_network #67151

GaryvanderMerwe mannequin opened this issue Nov 28, 2014 · 3 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@GaryvanderMerwe
Copy link
Mannequin

GaryvanderMerwe mannequin commented Nov 28, 2014

BPO 22962
Nosy @ncoghlan, @Kentzo

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2017-03-26.10:30:02.877>
created_at = <Date 2014-11-28.08:54:06.478>
labels = ['type-feature', 'library']
title = 'ipaddress: Add optional prefixlen argument to ip_interface and ip_network'
updated_at = <Date 2017-03-26.10:30:02.876>
user = 'https://bugs.python.org/GaryvanderMerwe'

bugs.python.org fields:

activity = <Date 2017-03-26.10:30:02.876>
actor = 'Gary.van.der.Merwe'
assignee = 'none'
closed = True
closed_date = <Date 2017-03-26.10:30:02.877>
closer = 'Gary.van.der.Merwe'
components = ['Library (Lib)']
creation = <Date 2014-11-28.08:54:06.478>
creator = 'Gary.van.der.Merwe'
dependencies = []
files = []
hgrepos = []
issue_num = 22962
keywords = []
message_count = 3.0
messages = ['231800', '290061', '290522']
nosy_count = 4.0
nosy_names = ['ncoghlan', 'pmoody', 'Gary.van.der.Merwe', 'Ilya.Kulakov']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue22962'
versions = ['Python 3.5']

@GaryvanderMerwe
Copy link
Mannequin Author

GaryvanderMerwe mannequin commented Nov 28, 2014

Currently if one has an ip address in int or IPv4Address/IPv6Address form, it is not possilbe to create a ip_interface or ip_network from that with specific prefix length, without first converting the address into string form, and then appending the prefixlen

Please could an optional prefixlen argument to ip_interface and ip_network (and the __init__ functions for their backing classes) so that one can do this.

e.g: it should work like this:

>>> ipaddress.ip_interface(167772161, prefixlen=24)
IPv4Interface('10.0.0.1/24')

I would like to do a patch for this. I would just first like some feedback as to whether a patch for this would accepted.

@GaryvanderMerwe GaryvanderMerwe mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Nov 28, 2014
@Kentzo
Copy link
Mannequin

Kentzo mannequin commented Mar 23, 2017

You can initialize ip_interface via a tuple of 2 elements: IP address and a prefix (prefixlen or string representation of a netmask).

I believe the issue can be closed now.

@GaryvanderMerwe
Copy link
Mannequin Author

GaryvanderMerwe mannequin commented Mar 26, 2017

Indeed. Thanks to whoever fixed this.

@GaryvanderMerwe GaryvanderMerwe mannequin closed this as completed Mar 26, 2017
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

0 participants