h0arry / ipaddr-py

Automatically exported from code.google.com/p/ipaddr-py
0 stars 0 forks source link

string based support for function and method arguments #30

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
A feature request that also exposes a few possible bugs when bad or
unexpected data is passed in via arguments. 

It would be nice to have string based arguments auto-detected when
specified by the end user.

What steps will reproduce the problem?

In [1]: from netaddr import *

In [2]: summarize_address_range('192.0.2.0', '192.0.2.255')
IPTypeError: first and last must be IP addresses, not networks

In [3]: collapse_address_list(['192.0.2.0/28', '192.0.2.16/28'])
AttributeError: 'str' object has no attribute '_prefixlen'

What is the expected output?

In [1]: from netaddr import *

In [2]: summarize_address_range('192.0.2.0', '192.0.2.255')
Out[2]: [IPv4Network('192.0.2.0/24')]

In [3]: collapse_address_list(['192.0.2.0/28', '192.0.2.16/28'])
Out[3]: [IPv4Network('192.0.2.0/27')]

What version of the product are you using?

ipaddr 2.0.x r97

Please provide any additional information below.

Using the copy constructor functionality of IPvXAddress or IPvXNetwork
objects on arguments passed into functions and methods would make this an
easy one to implement effectively and shouldn't noticeably slow code execution.

Original issue reported on code.google.com by drk...@gmail.com on 27 Aug 2009 at 9:44

GoogleCodeExporter commented 9 years ago

Original comment by pmo...@google.com on 29 Aug 2009 at 4:14

GoogleCodeExporter commented 9 years ago

Original comment by pmo...@google.com on 29 Aug 2009 at 4:14

GoogleCodeExporter commented 9 years ago
not going to implement this.  leads to inconsistent interface (or a lot of 
extra code 
to keep a consistent interface) and doesn't seem strictly pythonic.

>>> [1] + 2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can only concatenate list (not "int") to list

Original comment by pmo...@google.com on 18 Nov 2009 at 6:27