1

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?

2

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()
1

You just need to insert the \ character before the break line.

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.