'Check if the user has set the \'_\' variable by hand.'

def check_for_underscore(self):

    if ('_' in builtin_mod.__dict__):
        try:
            user_value = self.shell.user_ns['_']
            if (user_value is not self._):
                return
            del self.shell.user_ns['_']
        except KeyError:
            pass
