For context, I will use the example that prompted this question which is the DNA sequence class of Scikit-Bio.
The base class is a generic python sequence class. A Sequence class inherits from that class for sequences that are specifically nucleic acids (DNA, RNA ...). Finally, there is a DNA class that inherits from Sequence that enforces the specific alphabet of DNA.
So the following codes lists all the attributes of a DNA object.
from skbio import DNA
d = DNA('ACTGACTG')
for attr in dir(d):
# All the attributes of d.
How can I find which parent class each attribute belongs to? The reason why I am interested in this is that I am looking through the source code, and I want to be able to know which file I can find each method that I want to look at.
The best I can think of is something like this:
for attr in dir(d)
print type(attr)
But this just returns all string types (I guess dir() returns a list of strings).
How can I achieve this in python? Is there an inherent reason to not attemps this at all? Or is this something that comes up often in OOP?