Next / Previous / Contents / Shipman's homepage

6.8. lineno(): Convert a position to a line number

pp.lineno(loc, s)

The loc argument to this function is the location (Python index, counted from 0) of some position in a string s. The returned value is the line number of that position, counting from 1. Newlines ('\n') are treated as line separators. For an example demonstrating this function, see Section 6.1, “col(): Convert a position to a column number”.