Loading a predefined function
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?
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?
Have you tried attach
or load
? Or are you asking for something different?
Edit:
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:
Then you can refer to the data file foo.py
by doing something like attach(DATA+"foo.py")
, I think. The quote will be important, because I believe that DATA
is already a string giving the data directory for that worksheet.
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?
But the .py file is on my local drive, not on the VM drive ...
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 blah.py on the fly, possibly overwriting the existing blah.py.
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2012-02-11 10:26:47 +0100
Seen: 832 times
Last updated: Feb 17 '12