On Mon, Feb 19, 2018 at 11:32 PM, Rhodri James <rho...@kynesim.co.uk> wrote: > On 18/02/18 16:18, Wildman via Python-list wrote: >>> >>> But that's only going to show one (uplink) address. If I needed to get >>> ALL addresses for ALL network adapters, I'd either look for a library, >>> and if one wasn't easily found, I'd shell out to the "ip" command and >>> parse its output.:) >>> >> I considered using the "ip" command but I prefer not to >> depend on external programs if I can get around it. I >> know that might be considered silly but that's just me. > > > It's not silly at all, but for Linux networking it might be the best idea. > I believe in theory you are supposed to use libnl (in some suitable > wrapping), but my experience with that is that it is badly documented and > horrendously unreliable.
Agreed. Obviously the first choice is to look in the standard library for the functionality you want, but it's not there (at least, I couldn't find it). Then your next choices, if I'm not mistaken, are: * Random third-party packages you might find on PyPI * Opaque IOCTLs * Wrapping a poorly-documented C library * Invoking a subprocess and parsing its output When those are the choices, the subprocess option doesn't look too bad. ChrisA -- https://mail.python.org/mailman/listinfo/python-list