looping through a file

Bruno Desthuilliers bdesth.nospam at removeme.free.fr
Fri Jul 25 22:24:50 CEST 2003

Adam wrote:
> Psybar Phreak wrote:
>> hi all - ive just started with python (after having done java and c) 
>> and am
>> having a little bit of trouble with the script.  Im using as a login 
>> script.
>> There's a users.dat file in the format
>> user1
>> user1password
>> user2
>> user2password
>> ... etc
>> at the moment - the code i work, only checks the first and second 
>> lines (ie.
>> details of user1).  but it appears that python doesn't have a do... 
>> while...
>> until loop.

No, but there are better ways to do it in Python :

     thefile = file(filename)
except IOError:

for line in thefile.readlines():

More information about the Python-list mailing list