3 ms·
This is a pretty confused article. The author starts with a list of useful things which he then deems 'too complicated', and ends up with using a JSON based con
by orf 9y ago
This is a pretty confused article. The author starts with a list of useful things which he then deems 'too complicated', and ends up with using a JSON based config file. Ok. But the things he listed are not too complex, and the solution is a simple line-based config file of IP addresses:
import netaddr, sys
ips_to_connect_to = [*netaddr.IPGlob(ip) for ip in open(sys.argv[1])]
Those two lines handle points 1, 2 and 3 of his 'nice to haves'. You could easily add 4 and 5 in under 10 lines. You could expand it to read from stdin rather than a fixed file easily enough as well.
- sasa_buklijas 9y agoThank for mentioning http://netaddr.readthedocs.io/en/latest/ http://netaddr.readthedocs.io/en/latest/, I did not know about it.
- orf 9y agoThe built in ipaddress module is enough for your current use case, netaddr just handles globs.