Preload defined functions for later use

i like this post (click again to cancel)
1
i dont like this post (click again to cancel)

I have a couple of functions that I'd like to reuse when needed, but having to write them into each worksheet is annoying.

Is there a file/directory where I can put the functions such that they get loaded into every new worksheet?

asked Jan 19 '12

Josso gravatar image Josso
13 3

updated Jan 19 '12

kcrisman gravatar image kcrisman
6639 13 66 150

2 Answers:

i like this answer (click again to cancel)
3
i dont like this answer (click again to cancel) Josso has selected this answer as correct

Sure. From the Wiki FAQ (slightly differently worded at the Sage docs FAQ:

QUESTION: Is there anything so Sage can be made to automatically execute commands on startup? ANSWER: Yes, just make a file $HOME/.sage/init.sage and it will be executed any time you start sage.

link

posted Jan 19 '12

kcrisman gravatar image kcrisman
6639 13 66 150

For some reason SAGE_STARTUP_FILE wasn't set, but I just added export SAGE_STARTUP_FILE=$HOME/.sage/init.sage to my .bash_profile. :)

Josso (Jan 19 '12)
i like this answer (click again to cancel)
1
i dont like this answer (click again to cancel)

Alternatively, you can put the file somewhere on the filesystem or out on the web, and "load" it as the first command in your worksheet. You still have to type something in the worksheet, but it's one line.

link

posted Jan 19 '12

Jason Grout gravatar image Jason Grout
3185 7 27 71

How to "load" ??

Green diod (Jan 31 '12)

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[hide preview]

Question tools

1 follower

Tags:

Stats:

Asked: Jan 19 '12

Seen: 130 times

Last updated: Jan 19 '12

powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.