Ask Your Question

Loading a predefined function

asked 2012-02-11 03:26:47 -0500

Green diod gravatar image

updated 2012-02-12 12:08:11 -0500

One thread showed how to load functions at startup

But how to load some predefined function (or a bunch of functions from some .py file, say) only as needed?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2012-02-16 17:44:33 -0500

if you write your own Sage code, the better use the file extension .sage, not .py. Note that in .py files not all Sage library might be available.

There is also a catch that if you have .sage file, say, blah.sage, then Sage will create on the fly, possibly overwriting the existing

edit flag offensive delete link more

answered 2012-02-11 14:46:01 -0500

kcrisman gravatar image

updated 2012-02-13 06:54:35 -0500

Have you tried attach or load? Or are you asking for something different?


I imagine it would be a little challenging in the virtual machine. In the notebook interface, you should still be able to do it, though. Try using the link in the picture below:

C:\fakepath\Screen shot 2012-02-13 at 1.52.00 PM.png

Then you can refer to the data file by doing something like attach(DATA+""), I think. The quote will be important, because I believe that DATA is already a string giving the data directory for that worksheet.

edit flag offensive delete link more


No, I didn't try as I didn't know about these two functions. Could you please comment on the procedure to follow when Sage is running in a virtual machine? I know I can download and upload Sage worksheets from the notebook interface, say but how about plain .py scripts?

Green diod gravatar imageGreen diod ( 2012-02-12 01:54:42 -0500 )edit

But the .py file is on my local drive, not on the VM drive ...

Green diod gravatar imageGreen diod ( 2012-02-13 09:58:13 -0500 )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: 2012-02-11 03:26:47 -0500

Seen: 343 times

Last updated: Feb 16 '12