<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def stub(self, obj, attr=None):
        '''
        Stub an object. If attr is not None, will attempt to stub that
        attribute on the object. Only required for modules and other rare
        cases where we can't determine the binding from the object.
        '''
        s = stub(obj, attr)
        if s not in self._stubs:
            self._stubs.append(s)
        return s