looping through a file
Bruno Desthuilliers
bdesth.nospam at removeme.free.fr
Fri Jul 25 16:24:50 EDT 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 :
try:
thefile = file(filename)
except IOError:
doWhatEverWithException()
for line in thefile.readlines():
doWhatEverWithTheLine()
More information about the Python-list
mailing list