How to access the elements of Tupla?

0

How to access the elements of this tuple:

StringElement('24929426', attributes={'IdType': 'pubmed'})

I want to extract the attributes:

'24929426'
'IdType': 'pubmed'

The snippet of code that generates this output:

>>> from Bio import Entrez
>>> Entrez.email = "[email protected]"     # Always tell NCBI who you are
>>> handle = Entrez.esearch(db="pubmed", term="biopython")
>>> record = Entrez.read(handle)
>>> record["IdList"]
['24929426', '24497503', '24267035', '24194598', '23842806', '23157543', '22909249', '22399473', '21666252', '21210977', '20015970', '19811691', '19773334', '19304878', '18606172', '21585724', '16403221', '16377612', '14871861', '14630660']
>>> idlist = record["IdList"][0]
>>> handle = Entrez.efetch(db="pubmed", id=idlist, rettype="medline", retmode="xml")
>>> records = Entrez.read(handle)
>>> records[0]['PubmedData']
{'History': [DictElement({'Year': '2014', 'Month': '1', 'Day': '22'}, attributes={'PubStatus': 'received'}), DictElement({'Year': '2014', 'Month': '6', 'Day': '10'}, attributes={'PubStatus': 'accepted'}), DictElement({'Hour': '6', 'Year': '2014', 'Month': '6', 'Day': '16', 'Minute': '0'}, attributes={'PubStatus': 'entrez'}), DictElement({'Hour': '6', 'Year': '2014', 'Month': '6', 'Day': '16', 'Minute': '0'}, attributes={'PubStatus': 'pubmed'}), DictElement({'Hour': '6', 'Year': '2015', 'Month': '4', 'Day': '22', 'Minute': '0'}, attributes={'PubStatus': 'medline'})], 'ArticleIdList': [StringElement('24929426', attributes={'IdType': 'pubmed'}), StringElement('1756-0500-7-365', attributes={'IdType': 'pii'}), StringElement('10.1186/1756-0500-7-365', attributes={'IdType': 'doi'}), StringElement('PMC4094456', attributes={'IdType': 'pmc'})], 'PublicationStatus': 'epublish'}
>>> records[0]['PubmedData']['ArticleIdList']
[StringElement('24929426', attributes={'IdType': 'pubmed'}), StringElement('1756-0500-7-365', attributes={'IdType': 'pii'}), StringElement('10.1186/1756-0500-7-365', attributes={'IdType': 'doi'}), StringElement('PMC4094456', attributes={'IdType': 'pmc'})]
    
asked by anonymous 21.11.2016 / 15:42

0 answers