removing comments form a file
craig at postnewspapers.com.au
Mon Jan 3 10:28:32 EST 2005
On Mon, 2005-01-03 at 11:46 -0300, Batista, Facundo wrote:
> - Used file instead of open, to don't read the whole file in memory.
[craig at albert ~]$ python
Python 2.3.4 (#1, Oct 26 2004, 16:42:40)
.>>> file is open
.>>> print repr(file), repr(open)
<type 'file'> <type 'file'>
I'd be interested if you could clarify what you mean there. As far as I
know, the whole file will only be read into memory if you use file.read
() or file.readlines(). If you use an iterator it does internal
readahead, but won't read the lot at once. If you use read() it reads
only what you say.
More information about the Python-list