[Tutor] need a way to get my own ip address

jay titleistfour at gmail.com
Wed Jan 2 16:10:46 CET 2008


Well that is what I normally use, but I always have my hostname setup
properly.  In your case, that socket call won't work.  You could try this
link I found on google

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/439094

jay

On Jan 2, 2008 9:00 AM, shawn bright <nephish at gmail.com> wrote:

> It returns this
> ('hostname', [], ['127.0.1.1'])
> i am running this on a linux system
> thanks
>
>
> On Jan 2, 2008 8:50 AM, jay < titleistfour at gmail.com> wrote:
>
> > Well that will return the reverse lookup of the current hostname
> > assigned to your system.  Is this a Windows or Linux/Unix system?  What does
> > this return?
> >
> > print socket.gethostname()
> > print socket.gethostbyaddr(socket.gethostname ())
> >
> > j
> >
> >
> > On Jan 2, 2008 8:45 AM, shawn bright <nephish at gmail.com > wrote:
> >
> > > Thanks, Jay,
> > > in IDLE, this gave me 127.0.0.1
> > > is there a way to get my assigned ip instead of the localhost one?
> > > thanks
> > >
> > >
> > > On Jan 2, 2008 8:31 AM, jay < titleistfour at gmail.com> wrote:
> > >
> > > > You could perhaps use this method
> > > >
> > > > import socket
> > > > myIP = socket.gethostbyaddr(socket.gethostname())[2]
> > > >
> > > > Jay
> > > >
> > > > On Jan 2, 2008 8:25 AM, shawn bright < nephish at gmail.com> wrote:
> > > >
> > > > > Greetings,
> > > > >
> > > > > i am looking for an easy way to get my own ip address as a string
> > > > > from python.
> > > > > I am using Ubuntu Linux if that makes any difference.
> > > > > thanks !
> > > > >
> > > > > shawn
> > > > >
> > > > > _______________________________________________
> > > > > Tutor maillist  -  Tutor at python.org
> > > > > http://mail.python.org/mailman/listinfo/tutor
> > > > >
> > > > >
> > > >
> > > > _______________________________________________
> > > > Tutor maillist  -  Tutor at python.org
> > > > http://mail.python.org/mailman/listinfo/tutor
> > > >
> > > >
> > >
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080102/4a1ec2ed/attachment.htm 


More information about the Tutor mailing list