Sara Khalatbari <[EMAIL PROTECTED]> wrote:

>Dear friends
>In a code, I'm opening a file to read. Like :
>    lines = open(filename).readlines()
>& I'm never closing it.
>I'm not writing in that file, I just read it.
>
>Will it cause any problems if you open a file to read
>& never close it?

A file is closed when the last reference to it is deleted.  Since you never
save a reference to this file, the last reference is deleted as soon as the
readlines() call finishes.

So, the file will be closed when you move to the next statement.
-- 
- Tim Roberts, [EMAIL PROTECTED]
  Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to