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, 26 Sep 2017 02:05:17 -0500Project defined functionshttp://ask.sagemath.org/question/38974/project-defined-functions/Is it possible to define Project specific functions that all collaborators/students in the project can call as if it were globally defined? Mon, 25 Sep 2017 17:44:54 -0500http://ask.sagemath.org/question/38974/project-defined-functions/Answer by eric_g for <p>Is it possible to define Project specific functions that all collaborators/students in the project can call as if it were globally defined? </p>
http://ask.sagemath.org/question/38974/project-defined-functions/?answer=38975#post-id-38975I guess your question is referring to a CoCalc project. Then, it suffices to place the definition of the function in the file `.sage/init.sage` in the home directory of the project.
You can do this, for instance, by clicking on `Files`in the top menu bar, then click on the "eye" button on the top right (just at the left of the `Backups` button). The subdirectory `.sage` will then show up in the list; click on it and then click on `init.sage` to open it. You can enter the code of the function there and save it.
As an example, if you type the following two lines in that file:
def f(x):
return x^2
the function `f` will be available in any Sage session of the project.
Tue, 26 Sep 2017 02:05:17 -0500http://ask.sagemath.org/question/38974/project-defined-functions/?answer=38975#post-id-38975