I'd like to show you how to do it without actually having to execute the other file over and over again. The solution above is a little hacky, and makes the code in the other file confusing (Where does this x variable come from? and what is the f function?). Maybe the command above is just what you need, but with all the attention this question gets, I decided to add a few more cents to it for those who don't know how a more pythonic way would look like. Therefore, supplying -i does the trick: %run -i 'script.py' This is useful if you are experimenting with code written in a text editor which depends on variables defined interactively. i run the file in IPython’s namespace instead of an empty one. In the %run magic documentation you can find:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |