def add_line_numbers(source, start=<NUM_LIT:1>, n_digits=None):
was_string = isinstance(source, six.string_types)<EOL>part_lines = source.splitlines() if was_string else source<EOL>if n_digits is None:<EOL><INDENT>endline = start + len(part_lines)<EOL>n_digits = math.log(max(<NUM_LIT:1>, endline), <NUM_LIT:10>)<EOL>n_digits = int(math.ceil(n_digits))<EOL><DEDENT>src_fmt = '<STR_LIT>'<EOL>part_lines = [<EOL>src_fmt.format(n_digits=n_digits, count=count, line=line)<EOL>for count, line in enumerate(part_lines, start=start)<EOL>]<EOL>if was_string:<EOL><INDENT>return '<STR_LIT:\n>'.join(part_lines)<EOL><DEDENT>else:<EOL><INDENT>return part_lines<EOL><DEDENT>
Prefixes code with line numbers

Example:
    >>> print(chr(10).join(add_line_numbers(['a', 'b', 'c'])))
    1 a
    2 b
    3 c
    >>> print(add_line_numbers(chr(10).join(['a', 'b', 'c'])))
    1 a
    2 b
    3 c