I you are already used to some particular editor for coding, you can/should keep it, so that you will be at ease with it (shortcuts, syntaxic coloration,...). What is worth noticing, is that there are tools to ease a "store things in files and use them in a Sage console" workflow, whatever your editor is.
If you want to store some functions in a file and use them in a Sage shell you can do:
sage: %runfile('/path/to/file.sage')
and the file will be run once, or
sage: attach('/path/to/file.sage')
and the file will be re-run each time you save it (useful when you want to test its parts while modifying it).
If you name the file file.py
instead of file.sage
, then there will not be any Sage preparsing (e.g. ^
will not mean power
). Note that only .py
files are accepted in the Sage source code, so you should use them if you plan to insert your code as a part of Sage.
Now, if you want to import custom functions/classes/variables as modules with the import
command, you can store your my_file.py
files in some my_directory
, and tell Sage that this directory contains interesting things for it as follows:
import sys
sys.path.append('/path/to/my_directory/')
Then you can do:
from my_file import my_function
If you want to automatically append my_directory
at Sage startup, you can add the previous lines in the file $HOME/.sage/init.sage