On Wed, Sep 11, 2013 at 8:42 PM, Pranjal Mittal < pranjal.mittal.ec...@iitbhu.ac.in> wrote:
> Here you go- > > import socket > socket.gethostbyaddr(socket.gethostname())[2] > > > On Wed, Sep 11, 2013 at 8:16 PM, ashish makani <ashish.mak...@gmail.com > >wrote: > > > Found this quick, nifty way to determine the ip address of the machine > your > > py script is running on > > > > import commands > > commands.getoutput("/sbin/ifconfig").split("\n")[1].split()[1][5:] > > Several machines have multiple IP addresses, and 0x7f000001 is least interesting one.. On most modern linux distros, 'hostname -I' also works. >>> commands.getoutput('hostname -I').split() ['192.168.1.120', '11.22.103.1'] _______________________________________________ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers