Bob Smith wrote:
To do this efficiently on a large file (dozens or hundreds of megs), you
should use the 'sizehint' parameter so as not to use too much memory:
sizehint = 0
mylist = f.readlines(sizehint)
It doesn't make any difference. .readlines reads the entire file into
memory at once.
--
E
Erik Max Francis wrote:
Bob Smith wrote:
To do this efficiently on a large file (dozens or hundreds of megs),
you should use the 'sizehint' parameter so as not to use too much memory:
sizehint = 0
mylist = f.readlines(sizehint)
It doesn't make any difference. .readlines reads the entire file in
Erik Max Francis wrote:
>> To do this efficiently on a large file (dozens or hundreds of megs), you
>> should use the
>> 'sizehint' parameter so as not to use too much memory:
>>
>> sizehint = 0
>> mylist = f.readlines(sizehint)
>
> It doesn't make any difference. .readlines reads the entire fi
Xah Lee wrote:
# reading entire file as a list, of lines
# mylist = f.readlines()
To do this efficiently on a large file (dozens or hundreds of megs), you
should use the 'sizehint' parameter so as not to use too much memory:
sizehint = 0
mylist = f.readlines(sizehint)
--
http://mail.python.org
Xah Lee wrote:
> # the second argument of open can be
> # 'w' for write (overwrite exsiting file)
> # 'a' for append (ditto)
> # 'r' or read only
are you sure you didn't forget something?
> # reading the one line
> # line = f.realine()
wrong
> [...]
Maybe you didn't get the fact the you won't
# -*- coding: utf-8 -*-
# Python
# to open a file and write to file
# do
f=open('xfile.txt','w')
# this creates a file "object" and name it f.
# the second argument of open can be
# 'w' for write (overwrite exsiting file)
# 'a' for append (ditto)
# 'r' or read only
# to actually print to file