MCPcopy Index your code
hub / github.com/python/cpython / count_lines

Method count_lines

Lib/idlelib/squeezer.py:277–288  ·  view source on GitHub ↗

Count the number of lines in a given text. Before calculation, the tab width and line length of the text are fetched, so that up-to-date values are used. Lines are counted as if the string was wrapped so that lines are never over linewidth characters long.

(self, s)

Source from the content-addressed store, hash-verified

275 editwin.write = mywrite
276
277 def count_lines(self, s):
278 """Count the number of lines in a given text.
279
280 Before calculation, the tab width and line length of the text are
281 fetched, so that up-to-date values are used.
282
283 Lines are counted as if the string was wrapped so that lines are never
284 over linewidth characters long.
285
286 Tabs are considered tabwidth characters long.
287 """
288 return count_lines_with_wrapping(s, self.editwin.width)
289
290 def squeeze_current_text(self):
291 """Squeeze the text block where the insertion cursor is.

Callers 3

mywriteMethod · 0.95
squeeze_current_textMethod · 0.95
test_count_linesMethod · 0.80

Calls 1

Tested by 1

test_count_linesMethod · 0.64