Closing Output files

David Goodger dgoodger at bigfoot.com
Fri May 26 22:26:35 EDT 2000


on 2000-05-25 15:10, Michaell Taylor (Michaell.Taylor at reis.com) wrote:
> To accomplish this it seems that I must close the file (as shown), but once
> closed the same instance doesn't seem to write to it again even given a
> sys.stdout=progress_stamp command.

<snip>
 
> What am I missing?

Perhaps you forgot to reopen the file? Once closed, even assigning the file
descriptor to sys.stdout won't let you write to it. If this isn't the case,
perhaps show us the real code; it helps! :-)

BTW, the in the algorithm you show, unless you explicitly disallow it (by
some careful scheduling process, tricky business) you will have to take care
of cases when two processes simultaneously try to write to the file. If it
*can* happen, eventually it *will* happen. That's one reason why
client-server approaches are useful.

Also, why assign your output file to sys.stdout just to use print? Why not
use progress_stamp.write()? It seems clearer and less error-prone.

-- 
David Goodger    dgoodger at bigfoot.com    Open-source projects:
 - The Go Tools Project: http://gotools.sourceforge.net
 (more to come!)




More information about the Python-list mailing list