file opening and closing
anton muhin
antonmuhin at rambler.ru
Wed Dec 24 11:39:01 EST 2003
More information about the Python-list mailing list
Wed Dec 24 11:39:01 EST 2003
- Previous message (by thread): question on multithreading, pipes
- Next message (by thread): file opening and closing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
hokieghal99 wrote: > jpg = string.find(file(os.path.join(root,fname), 'rb').read(), 'JFIF') > > Should this file be closed after reading? If so, how would one close it? > What's the downside to not closing it? > It would, then the file object gets destroyed (it method __del__ is called). However, as Python uses garbage collection, it can happen much later after you leave the function. There is mostly no downsides except for the cases when you try to read this file---it might not be flashed. regards, anton.
- Previous message (by thread): question on multithreading, pipes
- Next message (by thread): file opening and closing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list