[Twisted-Python] Woven example for article, Part II
Moshe Zadka
m at moshez.org
Wed May 28 22:02:00 MDT 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')
...
page.close()
os.rename(PAGE+'.tmp', PAGE)
...
is safer, and lacks race condition. I really wish people would use it
more.
--
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