<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def __substitute_objects(self, value, context_dict):
 """ recursively substitute value with the context_dict """

        if type(value) == dict:
            return dict([(k, self.__substitute_objects(v, context_dict)) for k, v in value.items()])
        elif type(value) == str:
            try:
                return value % context_dict
            except KeyError:
                e = sys.exc_info()[1]
                logger.warn("Could not specialize %s! Error: %s" % (value, e))
                return value
        else:
            return value