<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def all_derived (type):
 """ Returns type and all classes that derive from it, in the order of their distance from type. """

    assert isinstance(type, basestring)
    result = [type]
    for d in __types [type]['derived']:
        result.extend (all_derived (d))

    return result