def get_ip_addresses(include_loopback=True):
 system = platform.system()
 if (system.lower() in ['linux', 'darwin', 'macosx']):
  ips = [iface.get('inet') for iface in ifcfg.interfaces().values()]
 elif (system.lower() == 'windows'):
  ipconfig = os.popen('ipconfig /all').read()
  ips = [match[1] for match in re.findall('IP(v4)? Address[\\.\\: ]+([\\d\\.]+)', ipconfig)]
 else:
  ips = []
 ips = (set(ips) - set([None, '']))
 if include_loopback:
  ips = ips.union(['127.0.0.1'])
 else:
  ips = (ips - set(['127.0.0.1']))
 return list(ips)

def get_ip_addresses ( include_loopback = True ) : system = platform . system ( ) if ( system . lower ( ) in [ 'linux' , 'darwin' , 'macosx' ] ) : ips = [ iface . get ( 'inet' ) for iface in ifcfg . interfaces ( ) . values ( ) ] elif ( system . lower ( ) == 'windows' ) : ipconfig = os . popen ( 'ipconfig /all' ) . read ( ) ips = [ match [ 1 ] for match in re . findall ( 'IP(v4)? Address[\\.\\: ]+([\\d\\.]+)' , ipconfig ) ] else : ips = [ ] ips = ( set ( ips ) - set ( [ None , '' ] ) ) if include_loopback : ips = ips . union ( [ '127.0.0.1' ] ) else : ips = ( ips - set ( [ '127.0.0.1' ] ) ) return list ( ips )
get a list of all the ip addresses for adapters on the local system .