<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def getname(obj):
 """ Return the most qualified name of an object :param obj: object to fetch name :return: name of ``obj`` """

    for name_attribute in ('__qualname__', '__name__'):
        try:
            # an object always has a class, as per Python data model
            return getattr(obj, name_attribute, getattr(obj.__class__, name_attribute))
        except AttributeError:
            pass
    raise TypeError('object of type %r does not define a canonical name' % type(obj))