[Tutor] Sloppy Code ?

Matt Erasmus matt.erasmus at gmail.com
Mon Nov 13 20:10:39 CET 2006


Hi Michael

Yes, that does help, although it doesn't print the FQDN which is what
I'm really after.
But thanks to you I now know about the socket module (is that the
right terminology ?) and using the Python script in Vim I found
socket.getfqdn() which prints exactly what I needed...

So my code goes from:

stdin, stdout, stderr = os.popen3('/bin/hostname -f')
system_name = stdout.read()
stdin.close()
stderr.close()
stdout.close()
...

to

report.write(socket.getfqdn())

On 13/11/06, Michael Lange <klappnase at freenet.de> wrote:
> import socket
> print socket.gethostname()
>
> I hope this helps

Thanks so much Michael

-Matt


More information about the Tutor mailing list