[Biopython] Entrez.read return value is typed as a string??
Michiel de Hoon
mjldehoon at yahoo.com
Thu Oct 29 03:50:07 UTC 2009
--- On Wed, 10/28/09, Ben O'Loghlin <bassbabyface at yahoo.com> wrote:
> >>>> handle = Entrez.efetch(db="pubmed", id="17206916", retmode="XML")
> >>>> record = Entrez.read(handle)
> >>>> print record
> >[{u'MedlineCitation': ... ]
>
> I'm interested in using this format, however I don't
> understand how to
> read/write fields and subtrees of the object type
> 'Bio.Entrez.Parser.ListElement' returned by
> Entrez.read(handle) with retmode XML.
>
> I'm finding it hard to track down references to this
> [{u'x':['y']}] object format in Python ...
Look at the outermost two brackets [].
You can treat this object as a Python list.
So if record = [{u'x':['y']}],
then record[0] = {u'x':['y']}
Now look at the two outermost braces {}.
You can treat record[0] as a dictionary.
So record[0]['x'] will return ['y'].
Which can then be treated as a Python list.
--Michiel.
More information about the Biopython
mailing list