First time here? Check out the FAQ!

Ask Your Question
0

Loading a predefined function

asked 13 years ago

Green diod gravatar image

updated 13 years ago

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?

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 13 years ago

kcrisman gravatar image

updated 13 years ago

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.

Preview: (hide)
link

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

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

Green diod gravatar imageGreen diod ( 13 years ago )
1

answered 13 years ago

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.

Preview: (hide)
link

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: 858 times

Last updated: Feb 17 '12