# 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?

Project defined functions

add a comment

2

I 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.

Please start posting anonymously - your entry will be published after you log in or create a new account.

Asked: ** 2017-09-26 00:44:54 +0200 **

Seen: **187 times**

Last updated: **Sep 26 '17**

plot sage Graphics() from jupyter notebok in CoCalc

Why does underscore for last output not work in worksheets uploaded from local SageMath to Cocalc?

Displaying images with matplotlib

What is useful for to upgrade a project or an account?

Plotly/Cufflinks and Jupyter Notebooks

LaTeX macros in Markdown on Cocalc

What is the exact difference between Sage and Cocalc?

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.