erogol
erogol

Reputation: 13614

Save the sequence of the written code to an export file in IPython?

I've written code and many functions inside IPython and now I want to export them to a file in a structured way as in a legible script.py. Is there any mechanism in Ipython to provide such an opportunity?

Upvotes: 0

Views: 95

Answers (2)

sanchitarora
sanchitarora

Reputation: 920

%save magic would work best for your current use case (where you have already written code and functions in ipython).

For future interactive programming sessions where you would like to save code later you might want to check out iPython notebook (1). Along with all existing iPython functionality and options for saving as plain python script or a reusable notebook, its great for interactive sessions.

Upvotes: 0

iMom0
iMom0

Reputation: 12921

Have you tried the %save magic:

Save a set of lines or a macro to a given filename.

Upvotes: 1

Related Questions