This question already has an answer here:
- Simulate interactive python session 1 answer
Considering the following interactive shell session.
Python 2.7.5+ (default, Feb 27 2014, 19:37:08)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 1+1
2
>>> 2+5
7
>>> "foo"
'foo'
>>>
Observe how, after every line, the interpreter will echo the result to the console.
If I put those same three commands into a script Foo.py
without print statements, there will be no output generated.
Is there a way to force the Python interpreter to generate the same output as it would under interactive mode without modifying the code to manually insert print statements?