Type of a data structure Dictionaries

0

I'm trying to count how many dictionaries there are in a list. But the condition is always false in if.

>>> type(record['TranslationStack'][0])
<class 'Bio.Entrez.Parser.DictionaryElement'>
>>> record['TranslationStack'][0]
{'Field': 'MeSH Terms', 'Count': '506695', 'Explode': 'Y', 'Term': '"nucleotides"[MeSH Terms]'}
>>> type(record['TranslationStack'][0]) is dict
False
    
asked by anonymous 22.11.2016 / 01:21

1 answer

0

The DictionaryElement elements are wrappers relative to the basic type of Python dict, and behave in much the same way, except because they have the 'attributes' property that captures XML attributes.

The code below should work:

str(type(record['TranslationStack'][0]))=="<class 'Bio.Entrez.Parser.DictionaryElement'>"
    
20.01.2017 / 04:00