Extracting Data From Classes In Python
1
0
Entering edit mode
13.0 years ago
Francis ▴ 60

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 • 15k views
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
7
Entering edit mode
13.0 years ago

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

ADD COMMENT
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 1752 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6