Ask Your Question
2

Preload defined functions for later use

asked 2012-01-19 09:21:43 +0100

Josso gravatar image

updated 2012-01-19 09:44:05 +0100

kcrisman gravatar image

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?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
4

answered 2012-01-19 09:43:38 +0100

kcrisman gravatar image

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.

edit flag offensive delete link more

Comments

1

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 gravatar imageJosso ( 2012-01-19 13:38:41 +0100 )edit
1

answered 2012-01-19 10:13:02 +0100

Jason Grout gravatar image

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.

edit flag offensive delete link more

Comments

How to "load" ??

Green diod gravatar imageGreen diod ( 2012-01-31 11:55:30 +0100 )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

1 follower

Stats

Asked: 2012-01-19 09:21:43 +0100

Seen: 1,230 times

Last updated: Jan 19 '12