Ask Your Question
0

Loading a predefined function

asked 2012-02-11 10:26:47 +0200

Green diod gravatar image

updated 2012-02-12 19:08:11 +0200

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
1

answered 2012-02-11 21:46:01 +0200

kcrisman gravatar image

updated 2012-02-13 13:54:35 +0200

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:

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

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.

edit flag offensive delete link more

Comments

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 08:54:42 +0200 )edit

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

Green diod gravatar imageGreen diod ( 2012-02-13 16:58:13 +0200 )edit
1

answered 2012-02-17 00:44:33 +0200

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.

edit flag offensive delete link more

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: 2012-02-11 10:26:47 +0200

Seen: 717 times

Last updated: Feb 17 '12