Historically it has been difficult to straightforwardly get the network address(es) of the machine on which your Python scripts are running without compromising the portability of your script.
As a result, when I needed to do this for the first time, I thought it would be best to write a Python module that would work on (at least) Mac OS X and Linux, and maybe other UNIX-like systems too. netifaces is the result.