[IPython-dev] saving/loading py files

Satrajit Ghosh satra@mit....
Sat Mar 31 17:21:35 CDT 2012


hi,

i'm giving a tutorial on monday and realized that at a certain stage of my
tutorial i will have to jump out of the notebook to create a file and
define a function and then continue in the notebook running the file with
'run'. (the reason is that the inspect module needs to find the function,
so i can't simply define it in a separate cell).

for now i can do something like the following to save the contents of a
cell:

---
with open('test.py', 'wt') as fp:
    fp.writelines(_i1)

new cell:
   run test.py
---

some questions regarding this approach:

- is there already some quicker way to achieve this?
- instead of _iX, could i use some variable to indicate the previous
spatial located cell?
- is there a way i can load a py file into a cell?

this allows me to essentially use the notebook from an remote browser (kind
of like an ide). especially give codemirror's capabilities, i can do a lot!

cheers,

satra
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-dev/attachments/20120331/a7d6da53/attachment.html 


More information about the IPython-dev mailing list