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

Function _more_lines

Lib/_pyrepl/simple_interact.py:81–97  ·  view source on GitHub ↗
(console: code.InteractiveConsole, unicodetext: str)

Source from the content-addressed store, hash-verified

79
80
81def _more_lines(console: code.InteractiveConsole, unicodetext: str) -> bool:
82 # ooh, look at the hack:
83 src = _strip_final_indent(unicodetext)
84 try:
85 code = console.compile(src, "<stdin>", "single")
86 except (OverflowError, SyntaxError, ValueError):
87 lines = src.splitlines(keepends=True)
88 if len(lines) == 1:
89 return False
90
91 last_line = lines[-1]
92 was_indented = last_line.startswith((" ", "\t"))
93 not_empty = last_line.strip() != ""
94 incomplete = not last_line.endswith("\n")
95 return (was_indented or not_empty) and incomplete
96 else:
97 return code is None
98
99
100def run_multiline_interactive_console(

Calls 6

_strip_final_indentFunction · 0.85
compileMethod · 0.45
splitlinesMethod · 0.45
startswithMethod · 0.45
stripMethod · 0.45
endswithMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…