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

Method push

Lib/code.py:306–327  ·  view source on GitHub ↗

Push a line to the interpreter. The line should not have a trailing newline; it may have internal newlines. The line is appended to a buffer and the interpreter's runsource() method is called with the concatenated contents of the buffer as source. If this i

(self, line, filename=None, _symbol="single")

Source from the content-addressed store, hash-verified

304 self.write('%s\n' % exitmsg)
305
306 def push(self, line, filename=None, _symbol="single"):
307 """Push a line to the interpreter.
308
309 The line should not have a trailing newline; it may have
310 internal newlines. The line is appended to a buffer and the
311 interpreter's runsource() method is called with the
312 concatenated contents of the buffer as source. If this
313 indicates that the command was executed or invalid, the buffer
314 is reset; otherwise, the command is incomplete, and the buffer
315 is left as it was after the line was appended. The return
316 value is 1 if more input is required, 0 if the line was dealt
317 with in some way (this is the same as runsource()).
318
319 """
320 self.buffer.append(line)
321 source = "\n".join(self.buffer)
322 if filename is None:
323 filename = self.filename
324 more = self.runsource(source, filename, symbol=_symbol)
325 if not more:
326 self.resetbuffer()
327 return more
328
329 def raw_input(self, prompt=""):
330 """Write a prompt and read a line.

Callers 1

interactMethod · 0.95

Calls 4

resetbufferMethod · 0.95
appendMethod · 0.45
joinMethod · 0.45
runsourceMethod · 0.45

Tested by

no test coverage detected