This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Extracting Data From Classes In Python

How can I extract data from a class in Python?

>>>Bio.Alphabet.RNAAlphabet  
<class Bio.Alphabet.RNAAlphabet at 0x01EBF420>

How can I extract, say for example, the letters of that Alphabet from that object in Byophthon?

python biopython

If this question solve your problem and your other question is redundant, please closing this other question. Cheers

If this question solved your problem and your other question is redundant, please closing this other question. Cheers

1 answer

Hi,

In order to know the possible methods (functions) or attributes of an object (the data contained within that object), you should use the following Python command:

dir(object_name)

In your case, this would probably give:

dir(Bio.Alphabet.RNAAlphabet)

This will tell you what you can use or visualize in the object.

I suggest that you take some time familiarizing yourself with classes and object oriented programming in Python

EDIT:

Let's say the name of the attribute containing the data is 'letters', you can print it like this:

print Bio.Alphabet.RNAAlphabet.letters

If you don't want to print it, put it in a variable or torture it however you like :P.

Cheers

i see. And once i find the data that is contained within the object, how can I call it?

Log in to answer this question.