[Tutor] Sloppy Code ?

Matt Erasmus matt.erasmus at gmail.com
Mon Nov 13 16:13:25 CET 2006


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....

Thanks in advance.

Matt E
matt.erasmus (at) gmail (dot) com


More information about the Tutor mailing list