r/Python • • Feb 28 '13

What's the one code snippet/python trick/etc did you wish you knew when you learned python?

I think this is cool:

import this

259 Upvotes

307 comments sorted by

View all comments

Show parent comments

3

u/[deleted] Feb 28 '13

Which part? The ipython part launches IPython. The %edit part says to open your text editor so you can use it instead of the interactive shell to input your code. When you close the editor IPython will run the code. And -p says to open the editor with whatever was in it the last time you used the edit command in this session. So you do %edit -p, put in some code, save and close the file and then it runs. Then you do %edit -p again and the same code comes back up for you to edit/run again.

2

u/[deleted] Feb 28 '13

And where do you define your default text editor?