Processing text using python

Steven Bethard steven.bethard at gmail.com
Mon Feb 20 11:44:58 EST 2006


danmcleran at yahoo.com wrote:
> I think this is what you want:
> 
> file = open(r'c:/test.txt','r')
> 
> c = file.read(3)
> while c:
>     print c
>     c = file.read(3)
> 
> file.close();


Or:

     def read3():
         return file.read(3)
     for chars in iter(read3, ''):
         ... do something with chars ...

STeVe



More information about the Python-list mailing list