will it cause any problems to open a read-only file & not close it?

John Machin sjmachin at lexicon.net
Mon Mar 14 07:23:35 EST 2005


Sara Khalatbari 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?

AFAIK, only if you try to have too many files open at one time -- many
appears to be approx 512 on recent Windows (2000 and XP at least).

However it's a very good habit whatever the language to close / delete
/ deallocate / ... any resource as soon as you no longer need it.




More information about the Python-list mailing list