MCPcopy Create free account
hub / github.com/ipython/ipython / get_pasted_lines

Function get_pasted_lines

IPython/terminal/magics.py:17–35  ·  view source on GitHub ↗

Yield pasted lines until the user enters the given sentinel value.

(sentinel, l_input=py3compat.input, quiet=False)

Source from the content-addressed store, hash-verified

15from IPython.utils import py3compat
16
17def get_pasted_lines(sentinel, l_input=py3compat.input, quiet=False):
18 """ Yield pasted lines until the user enters the given sentinel value.
19 """
20 if not quiet:
21 print("Pasting code; enter '%s' alone on the line to stop or use Ctrl-D." \
22 % sentinel)
23 prompt = ":"
24 else:
25 prompt = ""
26 while True:
27 try:
28 l = l_input(prompt)
29 if l == sentinel:
30 return
31 else:
32 yield l
33 except EOFError:
34 print('<EOF>')
35 return
36
37
38@magics_class

Callers 1

cpasteMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected