Hi I have three objects, all of them are instances of classes derived
from a base class. Now, given one of the instance, I want to find the
closest relative of the other two. How can I do this?

This is how I implemented; I guess there must be elegant way to do
this...

def find_closest_relative(a,b,c):
    c1 = b.__class__
    c2 = b.__class__

    while True:
        if isinstance(a, c1):
            return b
        if isinstance(a, c2):
            return c
        c1 = c1.__base__
        c2 = c1.__base__



-
Suresh

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to