Basic of the networking is the IP or the Internet Protocol address , every programming language has the ability to get the IP address of the host machine , python is not an exception of this . To get the host name and host address with python is very simple , just you need to import the socket module . and then some function and one shall able to get the IP address as well as the host address of the machine , here is the code
>>>import socket #importing socket
>>>MachineName = socket.gethostname(); # getting the machine name
>>>MachineIP = socket.gethostbyname(MachineName);#getting the IP address passing MachineName as parameter
The sample o/p look like this
>>>import socket #importing socket
>>>MachineName = socket.gethostname(); # getting the machine name
>>>MachineIP = socket.gethostbyname(MachineName);#getting the IP address passing MachineName as parameter
The sample o/p look like this