On Tuesday 24 November 2009, Shashwat Anand wrote:
On my openSuse 11.0 machine your method doesn't work as intended:


e...@lixie:~> python
Python 2.5.2 (r252:60911, Dec  1 2008, 18:10:01)
[GCC 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036]] on 
linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.gethostbyname(socket.gethostname())
'127.0.0.2'
>>>


It's a valid IP of my computer, but not the one you wanted. You could 
have written this one from memory (well I would have written 
127.0.0.1, which is also valid).  

Parsing the output from ifconfig would work for my computer. 


Kind regards,
Eike.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to