[pypy-dev] What's wrong with >>> open(’xxx’, ’w’).write(’stuff’) ?

William Leslie william.leslie.ttg at gmail.com
Thu Aug 19 07:13:36 CEST 2010


A good resource I recently read on this is this entry in Raymond Chen's blog:

http://blogs.msdn.com/b/oldnewthing/archive/2010/08/09/10047586.aspx

Together with the following entry, which explains why the lifetime of
the variable has nothing to do with the lifetime of the object, this
should help you understand.

You should consider automatically closing a file to be an
implementation detail, even cpython may not respect such semantics in
future. That is why the with statement was created.

-- 
William Leslie



More information about the Pypy-dev mailing list