On 8/30/06, Dan <[EMAIL PROTECTED]> wrote:
> Is this discouraged?:
>
>      for line in open(filename):
>          <do something with line>

In theory, it is. In practice, that is the way Python code is written
because it more natural and to the point. Not just for hacked together
scripts, lots of third party modules includes code like "data =
open(filename).read()" and similar idioms.

> Is my data safer if I explicitly close, like this?:
>      fileptr = open("the.file", "w")
>      foo_obj.write(fileptr)
>      fileptr.close()

Have you ever experienced a problem caused by not explicitly closing
your file handles?

-- 
mvh Björn
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to