2020-05-07 23:40:39 +02:00
|
|
|
import sys
|
|
|
|
from code import InteractiveInterpreter
|
|
|
|
|
2020-06-08 20:49:06 +02:00
|
|
|
|
2020-05-07 23:40:39 +02:00
|
|
|
def main():
|
|
|
|
"""
|
|
|
|
Print lines of input along with output.
|
|
|
|
"""
|
|
|
|
source_lines = (line.rstrip() for line in sys.stdin)
|
|
|
|
console = InteractiveInterpreter()
|
|
|
|
source = ''
|
|
|
|
try:
|
|
|
|
while True:
|
|
|
|
source = next(source_lines)
|
2020-06-08 20:49:06 +02:00
|
|
|
# Allow the user to ignore specific lines of output.
|
|
|
|
if not source.endswith('# ignore'):
|
|
|
|
print('>>>', source)
|
2020-05-07 23:40:39 +02:00
|
|
|
more = console.runsource(source)
|
|
|
|
while more:
|
|
|
|
next_line = next(source_lines)
|
|
|
|
print('...', next_line)
|
2020-06-08 20:49:06 +02:00
|
|
|
source += '\n' + next_line
|
2020-05-07 23:40:39 +02:00
|
|
|
more = console.runsource(source)
|
|
|
|
except StopIteration:
|
|
|
|
if more:
|
|
|
|
print('... ')
|
|
|
|
more = console.runsource(source + '\n')
|
|
|
|
|
2020-06-08 20:49:06 +02:00
|
|
|
|
2020-05-07 23:40:39 +02:00
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|