Ask Your Question

reuse scripts in Sage-NB

asked 2011-06-28 15:49:43 +0100

riemann gravatar image

updated 2011-06-28 17:22:23 +0100


I have some existing Python scripts and data on a machine with Sage-NB running. The Python script takes in the data file as the argument. Is there a way to use them in the Sage-NB interface?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2011-06-28 16:15:10 +0100

kcrisman gravatar image

updated 2011-06-28 21:57:47 +0100

This is really easy, I'm pleased as punch that this actually works, I'd never tried it.

  • Create a file. I made foo.sage, whose entire content is g(x)=x^2. I put it in my home directory.
  • Do load("~/foo.sage"), or whatever is appropriate for where your script lives.
  • Enjoy!

This should work with .py files as well. It's conceivable that you'll need appropriate permissions, etc.

If you have custom data to use as well, the best thing to do is see if the DATA variable will do what you need. This is documented in the "Help" link at the top of the notebook, and it should be pretty easy to upload an appropriate data file there as need be.

edit flag offensive delete link more


Thanks, it's much easier than I thought. That does work for all the *.py files and the data. Thanks for the help!

riemann gravatar imageriemann ( 2011-06-28 17:07:47 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2011-06-28 15:49:43 +0100

Seen: 282 times

Last updated: Jun 28 '11