[Python-Dev] PEP 3144 review. (original) (raw)
R. David Murray rdmurray at bitdance.com
Wed Sep 16 17:25:09 CEST 2009
- Previous message: [Python-Dev] PEP 3144 review.
- Next message: [Python-Dev] PEP 3144 review.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, 16 Sep 2009 at 12:50, exarkun at twistedmatrix.com wrote:
On 11:10 am, ncoghlan at gmail.com wrote:
Or, to put it another way, given an arbitrary host in a network (e.g. your own machine or the default gateway) and the netmask for that network, calculate the network address.
With a "lax" parser on IPNetwork this is a trivial task - just create the network object and then retrieve the network address from it. If, on the other hand, IPNetwork demands that you already know the network address before allowing you to create an IPNetwork object, then you're pretty much out of luck - if all you have to work with are the IP strings then this is actually a tricky calculation. If the default IPNetwork constructor was made more strict, then this functionality would have to be made available another way (probably as an alternate constructor like IPNetwork.fromhostaddress rather than as a boolean 'strict' option) This seems to be the right solution to me, particularly the use of an alternate constructor rather than an ambiguously named flag.
+1
--David
- Previous message: [Python-Dev] PEP 3144 review.
- Next message: [Python-Dev] PEP 3144 review.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]