Question: Extracting Data From Classes In Python
0
gravatar for Francis
2.9 years ago by
Francis50
Francis50 wrote:

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?

ADD COMMENTlink modified 2.9 years ago by Eric Normandeau7.1k • written 2.9 years ago by Francis50

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

ADD REPLYlink written 2.9 years ago by Eric Normandeau7.1k

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

ADD REPLYlink written 2.9 years ago by Eric Normandeau7.1k
7
gravatar for Eric Normandeau
2.9 years ago by
Eric Normandeau7.1k
Quebec, Canada
Eric Normandeau7.1k wrote:

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 COMMENTlink modified 2.9 years ago • written 2.9 years ago by Eric Normandeau7.1k

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

ADD REPLYlink written 2.9 years ago by Francis50
Please log in to add an answer.

Help
Access
  • RSS
  • Stats
  • API

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.0.0
Traffic: 344 users visited in the last hour