<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def pretty_print(self, carrot=True):
 """Print the previous and current line with line numbers and a carret under the current character position. Will also print a message if one is given to this exception. """

        output = ['\n']
        output.extend([line.pretty_print() for line in
                       self.partpyobj.get_surrounding_lines(1, 0)])

        if carrot:
            output.append('\n' +
                          (' ' * (self.partpyobj.col + 5)) + '^' + '\n')
        if self.partpymsg:
            output.append(self.partpymsg)

        return ''.join(output)