[Biopython] A potential printing error in the Biopython Tutorial and Cookbook?

Peter biopython at maubp.freeserve.co.uk
Fri Dec 11 14:45:31 EST 2009


On Fri, Dec 11, 2009 at 6:32 PM, ANGEL VILLAHOZ-BALETA
<villahozbale at wisc.edu> wrote:
> Hi to all,
>
> I believe that there is a printing error in the Biopython Tutorial and Cookbook...
>
> Go there:
>
> http://www.biopython.org/DIST/docs/tutorial/Tutorial.html#htoc102
>
> Then check the following source code:
>
>>>> for record in records:
> ...     print "title:", record["TI"]
> ...     if "AU" in records:
> ...         print "authors:", record["AU"]
> ...     print "source:", record["CO"]
> ...     print
>
> I believe that the if sentence would have the record
> instead of the records because it would never print
> such an information about the authors since the data
> structure of records does not have this key but always
> integers as its indices.

What version of Biopython do you have?
Could you show us the actual error message?

I've just been playing with the example, and for some
records certain fields are missing (you get a KeyError),
so this works better:

for record in records:
    print "title:", record.get("TI","?")
    print "author:", record.get("AU","?")
    print "source:", record.get("CO","?")
    print

Does that help?

Peter



More information about the Biopython mailing list