[Tutor] Sloppy Code ?
Michael Lange
klappnase at freenet.de
Mon Nov 13 19:51:15 CET 2006
On Mon, 13 Nov 2006 17:13:25 +0200
"Matt Erasmus" <matt.erasmus at gmail.com> wrote:
> Hi guys
>
> Very new to python programming but am really enjoying it.
>
> Anyway, I was just wondering if this code could be improved on in anway.
>
> ...
> stdin, stdout, stderr = os.popen3('/bin/hostname -f')
> system_name = stdout.read()
> stdin.close()
> stderr.close()
> stdout.close()
> ...
> report.write("System Report for: ")
> report.write(system_name)
> ...
>
> Is there a better way of doing this ? It works for what I want to do,
> but I would
> like to know if there's another way of doing things....
>
import socket
print socket.gethostname()
I hope this helps
Michael
More information about the Tutor
mailing list