[Tutor] files

Ricardo Aráoz ricaraoz at gmail.com
Sun Sep 2 00:41:48 CEST 2007


Hi, I am in doubt :

>>> In = open(r'E:\MyDir\MyDoc.txt', 'rb')
>>> Out = open(r'E:\MyDir\MyUpperDoc.txt', 'wb')
>>> Out.write(In.read().upper())
>>> In.close()
>>> Out.close()

Pretty simple program. The question is : If 'In' is a HUGE file, how
does Python process it? 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 into
memory and then passes the whole file to 'Out'?
If the answer is the first choice I would like to know how to instruct
Python to do the second choice.

TIA


More information about the Tutor mailing list