Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

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()
share|improve this answer

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

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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