rahmad akbar <matbioi...@gmail.com> Wrote in message:
>
> 
 then i realized i couldn't do something like .next() to the var in_file which 
is a list. so i added a flag start = False in which will be turned to True upon 
'Rich Roberts' found. is the any simpler way to move to the next element in the 
list. like built in method or something like that. 

def read_bionet(bionetfile):
  res_enzime_dict = {}
  in_file = open(bionetfile, 'r').readlines()
  start = False
  for line in in_file:
    if line.startswith('Rich Roberts'):

........

If you omit the call to readlines,  then in_file is a file object
 instead of a list. A file object is its own iterator,  and has a
 next () method.  You could also change readlines to xreadlines
 but I don't see the advantage. 

Another plus is saving all that memory that a list would take.
-- 
DaveA

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to