[Biopython-dev] Python 2.3

Jeffrey Chang jchang at smi.stanford.edu
Tue Aug 5 13:14:04 EDT 2003


On Tuesday, August 5, 2003, at 12:32  AM, Andreas Kuntzagk wrote:

> Btw. I was thinking, is there a better way to use the Iterator-classes
> in the different Modules?
>
> Up to now, I do it like this:
> Parser = GenBank.RecordParser()
> File = open ("foo")
> Iterator = GenBank.Iterator(File,parser=Parser)
> while 1:
>     record = it.next()
>     if not record: break
>     ...
>
> I think, nicer looking would be:
>
> File = GenBank.Flatfile("foo",Parser)
> for record in File:
>     # work with record

Yes, that is much nicer.  We can do that, now that we require Python 
2.2.  However, the code usually lags behind somewhat, because people 
are reluctant to change working code (and update the documentation), 
and break people's code.  I did go back and add iterator support to the 
Medline code, which introduced some bugs that are now fixed in the CVS. 
  :(

But yes, I think using iterators is cleaner, and should be done at some 
point.

Jeff




More information about the Biopython-dev mailing list