On 16 Sep 2009, at 01:05, Peter Moody wrote: > On Tue, Sep 15, 2009 at 4:34 PM, Scott Dial > <scott+python-dev at scottdial.com> wrote: >> R. David Murray wrote: >>> On Tue, 15 Sep 2009 at 21:58, Antoine Pitrou wrote: >>>> Le mardi 15 septembre 2009 à 15:48 -0400, R. David Murray a écrit : >>>>> However, I do not think >>>>> that the proposed API should accept, eg, IPv4Network >>>>> ('192.168.1.1/24') >>>>> as valid. That's just too confusing and error prone. >>>> >>>> Indeed, it should throw some kind of ValueError instead. >>> >>> Peter, what do you think? > > I disagree. It seems overly pedantic to throw a valueerror on this. > IPy does (used to do?) this and it's one of the primary reasons I > wrote ipaddr. I've seen user interfaces accept 192.168.1.1/24 as a short cut to set the ipaddr and netmask on an interface. For that use being able to parse that string into an IP Address and a Net Mask is what they want. If this is a common idiom having a utility function that returned an IPv4Address('192.168.1.1') and IPv4Network('192.168.0.0') would be useful. If someone really thinks that '192.168.1.1/16' is a network any good UI should detect it is invalid report that to the user. If you think this is a decision that the only the caller can decide why not add a keyword param to control the parsing? IPv4Network( '192.168.1.1/16', syntax='loose' ) (I'm sure syntax='loose' is not right but you get the idea.) Barry
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4