[Twisted-Python] Woven example for article, Part II

Moshe Zadka m at moshez.org
Thu May 29 00:02:00 EDT 2003

On Wed, 28 May 2003, "Dr. David Mertz" <gnosis at gnosis.cx> wrote:

> #!/usr/bin/env python2.2
> def update():
>     page = open(PAGE,'w')
>     for rec in RECS:
>             print >> page, ROW % (COLOR[odd], hit[referrer], resource)
>     print >> page, END
>     page.close()

Please don't do this kind of things in example code:

page = open(PAGE+'.tmp', 'w')
os.rename(PAGE+'.tmp', PAGE)

is safer, and lacks race condition. I really wish people would use it

Moshe Zadka -- http://moshez.org/
Buffy: I don't like you hanging out with someone that... short.
Riley: Yeah, a lot of young people nowadays are experimenting with shortness.
Agile Programming Language -- http://www.python.org/

More information about the Twisted-Python mailing list