• First of, you can move your *_patient_list into the Patient class to reduce global variables.

    class Patient(object): master_patient_list = [] # this should be shared among all Patients def __init__(self, ...): ... self.master_patient_class.append(self)

    Second, I think you want something like this for example:

    class Physician(Employee): illness2doctor = {} # shared dict mapping illness -> doctor for illness def __init__(self, name): # just as example self.name = name @classmethod def register_doctor(cls, doctor, illness): assert not illness in cls.illness2doctor # prevent overwrite cls.illness2doctor[illness] = doctor @classmethod def get_doctor_for(cls, patient): illness = patient.illness if illness not in cls.illness2doctor: raise KeyError("No doctor for illness") return cls.illness2doctor[illness] # --- usage --- # create a new physician alice = Physician(name="Alice") # alice can treat "Broken Leg" Physician.register_doctor(alice, "Broken Leg") # now we can get the doctor for patient1 print(Physician.get_doctor_for(patient1).name) # -> should print "Alice"
  • Wow, that's fantastic. It. Must of been done before I started using 1.6. I have been reading the release notes, but not all the history. I should have. But this is great....
    Thanks guys...

Internal error.

Oops! Looks like something went wrong!