473,385 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Visualize class inheritance hierarchy

Hi All,

I just finished debugging some code where I needed to determine why
one subclass had a bound method and another did not. They had
different pedigree's but I didn't know immediately what the
differences were.

I ended up walking the hierarchy, going back one class at a time
through the code, for the two subclasses (hierarchy ~7 classes deep
each) to see whom they inherited from. Short of writing this down on
paper, is there any way to graphically display the pedigree of an
object/class? "Graphically" can be text output to the terminal, don't
need anything special...

I'm assuming this has been discussed before, but I'm lacking any
Google keywords that bring up the appropriate discussion.

Cheers,
Rob
Sep 23 '08 #1
2 2682
On Sep 23, 5:53*pm, Rob Kirkpatrick <robert.d.kirkpatr...@gmail.com>
wrote:
Hi All,

I just finished debugging some code where I needed to determine why
one subclass had a bound method and another did not. *They had
different pedigree's but I didn't know immediately what the
differences were.

I ended up walking the hierarchy, going back one class at a time
through the code, for the two subclasses (hierarchy ~7 classes deep
each) to see whom they inherited from. *Short of writing this down on
paper, is there any way to graphically display the pedigree of an
object/class? *"Graphically" can be text output to the terminal, don't
need anything special...

I'm assuming this has been discussed before, but I'm lacking any
Google keywords that bring up the appropriate discussion.

Cheers,
Rob
Compare their __mro__ members if they are new-style. The depth-first
search for the member you're looking for is straightforward in Python,
even if maybe not immediately obvious.

If not, we can try a settrace and a search for when they are defined,
and build an __mro__ manually.
Sep 24 '08 #2
On Sep 23, 5:53*pm, Rob Kirkpatrick <robert.d.kirkpatr...@gmail.com>
wrote:
Hi All,

I just finished debugging some code where I needed to determine why
one subclass had a bound method and another did not. *They had
different pedigree's but I didn't know immediately what the
differences were.

I ended up walking the hierarchy, going back one class at a time
through the code, for the two subclasses (hierarchy ~7 classes deep
each) to see whom they inherited from. *Short of writing this down on
paper, is there any way to graphically display the pedigree of an
object/class? *"Graphically" can be text output to the terminal, don't
need anything special...

I'm assuming this has been discussed before, but I'm lacking any
Google keywords that bring up the appropriate discussion.

Cheers,
Rob
If you're using new-style classes, check out the __mro__ member, which
no doesn't show up in its dir(). Otherwise, we can try a settrace
(frame.f_code.co_name has the name of the class being defined in a
class statement) or accumulate some class statements with a custom
'parser' run in the module 'parser'.

Sep 24 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: mead | last post by:
What kind of classes is qualified as "concrete classes"? When should a member function in a class defined as "pure virtual" and when as "virtual"? Thanks!
18
by: Bradley | last post by:
I'm trying to determine if there's a general rule for when an Interface should used vs. an Abstract Class. Is there any design advantage to using one or the other? Brad
11
by: Darren.Ratcliffe | last post by:
Hi guys Posted what was probably a rather confusing post about this the other day, so I am going to have another go and see if I can make more sense. This sis purely a I've got a base class...
26
by: nyathancha | last post by:
Hi, How Do I create an instance of a derived class from an instance of a base class, essentially wrapping up an existing base class with some additional functionality. The reason I need this is...
3
by: krzysztof.konopko | last post by:
Hello! I want to design a class hierarchy with one base abstract class, let's say CBase. I have a predicate that every object in the class hierarchy must have a parent object of type from this...
14
by: Jo | last post by:
Hi, Is there a generic way to access the (virtual) functions in the base class of a class? Like in: if (!this->Foo(something)) return(((Base*)this)->Foo(something)); // for a normal member...
12
by: Gordon | last post by:
I want to provide a set of static functions in a superclass that work with class constants defined in a decendant of that class. Unfortunately I've run into a snag with this idea. Example: ...
3
by: Rahul | last post by:
While reading Inside the C++ object model I came through the following paragraph Point3d origin, *ptr = &origin; A) origin.x = 0.0; B) ptr->x = 0.0; The book says "A & B statements performs...
6
by: Nikola | last post by:
Is it possible in C++ to create a class hierarchy by inheritance that spans across various namespaces? For example, say I want to create a class which would behave like object type in C#, so...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.