Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add writeandexecute magic #11

Merged
merged 1 commit into from Jun 19, 2013

Conversation

Projects
None yet
2 participants
Contributor

janschulz commented Jun 18, 2013

This magic can be used to write the content of a cell to a .py
file and afterwards execute the cell. This can be used as a
replacement for the --script parameter to the notebook server.

Code is replaced on the next execution (using the needed identifier)
and other code can be appended by using the same file name.

Example:

%%writeandexecute -i <identifier> <filename>
print "Hello world"

This would write the print "Hello World" with the some surrounding
comments to the file "filename.py".

Cell content is transformed, so %%magic commands executeable, but
only in an ipython environment, as it depends on a working
get_ipython().

This is fixes ipython/ipython#3295

Add writeandexecute magic
This magic can be used to write the content of a cell to a .py
file and afterwards execute the cell. This can be used as a
replacement for the --script parameter to the notebook server.

Code is replaced on the next execution (using the needed identifier)
and other code can be appended by using the same file name.

Example:
```
%%writeandexecute -i <identifier> <filename>
print "Hello world"
```

This would write the `print "Hello World" with the some surrounding
comments to the file "filename.py".

Cell content is transformed, so %%magic commands executeable, but
only in an ipython environment, as it depends on a working
`get_ipython()`.
Owner

minrk commented Jun 18, 2013

Why do you want to add this to my personal extensions? It should be in your extensions.

Contributor

janschulz commented Jun 18, 2013

ipython/ipython#3312 (comment)

I'm happy taking more extensions into my repo, though I think we do want to figure
out a more central repository and/or index of extensions, so that we can remove
the R magic, etc. from the IPython repo.

Owner

minrk commented Jun 19, 2013

makes sense.

minrk added a commit that referenced this pull request Jun 19, 2013

@minrk minrk merged commit d16714b into minrk:master Jun 19, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment