ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 31 Jan 2012 04:55:30 -0600Preload defined functions for later usehttp://ask.sagemath.org/question/8646/preload-defined-functions-for-later-use/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?Thu, 19 Jan 2012 02:21:43 -0600http://ask.sagemath.org/question/8646/preload-defined-functions-for-later-use/Answer by kcrisman for <p>I have a couple of functions that I'd like to reuse when needed, but having to write them into each worksheet is annoying.</p>
<p>Is there a file/directory where I can put the functions such that they get loaded into every new worksheet?</p>
http://ask.sagemath.org/question/8646/preload-defined-functions-for-later-use/?answer=13151#post-id-13151Sure. From [the Wiki FAQ](http://wiki.sagemath.org/faq) (slightly differently worded at the [Sage docs FAQ](http://www.sagemath.org/doc/faq/faq-usage.html#can-i-make-sage-automatically-execute-commands-on-startup):
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.Thu, 19 Jan 2012 02:43:38 -0600http://ask.sagemath.org/question/8646/preload-defined-functions-for-later-use/?answer=13151#post-id-13151Comment by Josso for <p>Sure. From <a href="http://wiki.sagemath.org/faq">the Wiki FAQ</a> (slightly differently worded at the <a href="http://www.sagemath.org/doc/faq/faq-usage.html#can-i-make-sage-automatically-execute-commands-on-startup">Sage docs FAQ</a>:</p>
<p>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.</p>
http://ask.sagemath.org/question/8646/preload-defined-functions-for-later-use/?comment=20488#post-id-20488For some reason SAGE_STARTUP_FILE wasn't set, but I just added ``export SAGE_STARTUP_FILE=$HOME/.sage/init.sage`` to my .bash_profile. :)Thu, 19 Jan 2012 06:38:41 -0600http://ask.sagemath.org/question/8646/preload-defined-functions-for-later-use/?comment=20488#post-id-20488Answer by Jason Grout for <p>I have a couple of functions that I'd like to reuse when needed, but having to write them into each worksheet is annoying.</p>
<p>Is there a file/directory where I can put the functions such that they get loaded into every new worksheet?</p>
http://ask.sagemath.org/question/8646/preload-defined-functions-for-later-use/?answer=13152#post-id-13152Alternatively, 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.Thu, 19 Jan 2012 03:13:02 -0600http://ask.sagemath.org/question/8646/preload-defined-functions-for-later-use/?answer=13152#post-id-13152Comment by Green diod for <p>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.</p>
http://ask.sagemath.org/question/8646/preload-defined-functions-for-later-use/?comment=20377#post-id-20377How to "load" ??Tue, 31 Jan 2012 04:55:30 -0600http://ask.sagemath.org/question/8646/preload-defined-functions-for-later-use/?comment=20377#post-id-20377