Python get's a mention on University Challenge

Peter Hansen peter at engcorp.com
Mon Jun 2 21:50:27 EDT 2003


"Greg Ewing (using news.cis.dfn.de)" wrote:
> 
> Phil Thompson wrote:
> > Maybe prayer should be added as a transport to Twisted?
> 
> Should be simple enough:
> 
> def pray(text):
>    open("/dev/god", "w").write(text)

Oh, you don't want to do that!  If god actually exists,
that will overwrite it.

Always open god in append mode.

Also, using "ab" for binary mode will ensure that your
applications are portable to other religions.

Finally, it is best to close() god in a finally clause,
to ensure you free up the resource so others can pray too,
even though most documentation implies that many processes
can have god open at the same time.

-Peter




More information about the Python-list mailing list