ricaraoz at gmail.com
Sun Sep 2 02:53:16 CEST 2007
Alan Gauld wrote:
> "Ricardo Aráoz" <ricaraoz at gmail.com> wrote
>>>>> In = open(r'E:\MyDir\MyDoc.txt', 'rb')
>>>>> Out = open(r'E:\MyDir\MyUpperDoc.txt', 'wb')
>> Pretty simple program. The question is : If 'In' is a HUGE file, how
>> does Python process it?
> Exactly as it does for a small file... :-)
>> Does it treat it as a stream and passes bytes to
>> 'Out' as soon as they are coming in, or does it read the whole file
>> memory and then passes the whole file to 'Out'?
> You have told it to do the latter.
> read() reads the whole file into a string so
> Is exactly the same as
> temp = In.read()
> temp = temp.upper()
> Just because you put it in one line doesn't chanhge how
> Python interprets it.
>> If the answer is the first choice I would like to know how to
>> Python to do the second choice.
> I'm guessing you mean this the other way around?
> You can read the file line by line
> for line in In:
Thanks a lot.
More information about the Tutor