Closed GoogleCodeExporter closed 9 years ago
the tuple creator seems to be a special case, so I don't think that it belongs
in ipaddr
itself.
can you explain a little more about the list creator? Is the idea that you'd
pass it a list of
strings and get back a list of address objects?
Original comment by pmo...@google.com
on 2 Feb 2010 at 7:19
Supporting tuples (and lists) in the initializer would be extremely handy for
handling SNMP OIDS:
They look like:
$ snmpwalk -v2c -c public localhost 1.3.6.1.2.1.4.20.1 | head -n1
IP-MIB::ipAdEntAddr.127.0.0.1 = IpAddress: 127.0.0.1
$ snmpwalk -On -v2c -c public localhost 1.3.6.1.2.1.4.20.1 | head -n1
.1.3.6.1.2.1.4.20.1.1.127.0.0.1 = IpAddress: 127.0.0.1
so (suppose i know that the prefixlen for 127.0.0.1 is 4):
print [int(i) for i in ".1.3.6.1.2.1.4.20.1.1.127.0.0.1".split(".")[-4:]]
[127, 0, 0, 1]
or (for handy use as a key in a dict), a tuple:
print tuple([int(i) for i in ".1.3.6.1.2.1.4.20.1.1.127.0.0.1".split(".")[-4:]])
(127, 0, 0, 1)
Note that i don't really care if the list entries are string or int, it can be
trivially both.
See?
Original comment by rep.dot....@gmail.com
on 2 Feb 2010 at 8:42
I don't think that this belongs in the core library, but you can take this up
on ipaddr-
py-dev@googlegroups.com and see if other folks want it.
for now, I'm going to close this out.
Original comment by pmo...@google.com
on 5 Feb 2010 at 11:07
Original issue reported on code.google.com by
rep.dot....@gmail.com
on 11 Jan 2010 at 9:14