Python Forum

Full Version: How can I create a multiline input in ipython?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Dear all

I am working with the book Python Data Science Handbook by Jake VanderPlas. The author uses ipython in the book.

There are some code examples where the input consists of multiple lines (without execution). For example:

In[1]: L = list(range(10))
       L 
Out[1]: [0,1,2,3,4,5,6,7,8,9]
How can I type that in that without executing the first line (when hitting enter)? enter+shift does not work, I have tried that out.

Thanks for your help!
You are at the command line, so what you type will be executed.
To create a program and then run it I'd recommend using an IDE. Anaconda Spyder uses iPython as its engine and is a good IDE where you can create programs, then run them. Similarly, Jupyter Notebook (also part of Anaconda world)will give that same functionality.
If you think about your question ('How can I type that in that without executing the /../ line') then answer is quite obvious: you comment this line out (or delete altogether).

If you mean something else by 'without executing' then please clarify.
Ok, thanks @jefsummers, @perfringo