First time here? Check out the FAQ!

Ask Your Question
1

reuse scripts in Sage-NB

asked 13 years ago

riemann gravatar image

updated 13 years ago

Hi!

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?

Thanks,

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 13 years ago

kcrisman gravatar image

updated 13 years ago

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.

Preview: (hide)
link

Comments

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 ( 13 years ago )

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 13 years ago

Seen: 374 times

Last updated: Jun 28 '11