Know the type of return of a given

0

I have a problem with the return type of a data in python. First I was trying:

    >>> type(record[0][keys[2]])
<class 'Bio.Entrez.Parser.StringElement'>

I tried to check for if

>>> type(record[0][keys[2]])is list
>>> type(record[0][keys[2]])is string
>>> type(record[0][keys[2]])is array

all return Falso

I've also compared the integer type 'Bio.Entrez.Parser.StringElement' and also Falso . So I changed the abortion I'll see if there is a string type I want in the <class 'Bio.Entrez.Parser.StringElement'> of the type function to do this comparison I have to get the string inside < > so I can make that comparison? How to do this?

    
asked by anonymous 04.12.2016 / 14:28

2 answers

0

Express doing so:

type(<Objecto>) is <Tipo>

For example:

type("Eu sou uma String!") is str # => True
    
04.12.2016 / 14:58
0

Use 'isinstance'. example:

if isinstance(<Object>, <Class>):
    faz qualquer coisa
else:
    faz outra coisa
    
21.12.2016 / 05:09