I want to encode a python command in the terminal but it executes them as I press enter to go to the next line of command. How can I prevent the terminal from executing the command until I finish typing all the command lines?
3 Answers
I think you can write like following lines.
>>>if True:
>>> a = 10
>>> b = 5
>>> c = a + b
>>> print a, "+", b, "=", c
>>>
p.s. I think there is other way is that you define a function.
>>>def testfunc():
>>> a = 10
>>> b = 5
>>> c = a + b
>>> print a, "+", b, "=", c
>>>
>>>testfunc()
It's not a bug, it's a feature :)
The "problem" that you describe is in fact what you usually want in an interactive environment, be it the Python interpreter itself, IDLE or ipython.
It you want an environment, where you can type a couple of lines and then explicitely let it interpret/execute, give the browser-based IPython Notebook a try.