I'm looking to write some reusable code to do things like parse a particular file format outputted by some of my tools, but I don't see a particularly obvious "right way" to do this. I can define a python module, add it to the python path using the init.sage file, and then import it, but then I don't get some of the nice features I would get if I just loaded a .sage file from my current directory (namely tab-complete...).
Is there a preferred directory where I can save .sage files for use with the "load" commmand? If so, is there a way to specify a directory that is not in the SAGE_ROOT area, so I can source-control my specific .sage files independent of the sage installation?
asked Mar 17 '11NevilleS
121 ● 2 ● 3 ● 7
This may not be the "right way" to do it, but here is what I do:
In my home directory, in the .sage subdirectory I have the following "init.sage" file:
CODE = '/home/mike/Projects/Sage/' attach CODE+'defaults.sage'
Everything that I always want is in defaults.sage. Then in a particular sage program, I do something like:
attach CODE+'Differential_Equations/series.sage' attach CODE+'Differential_Equations/pde_misc.sage' attach /home/mike/Projects/Science/Electrodynamics/Electrostatics.sage
Note that while a couple of the things I needed were in my default "CODE" place, one of them was just in a random directory, so I had to include the whole path.
This certainly isn't perfect, but it's the best thing that I have found to do. I would also be interested in hearing other ideas. Figuring out the best was to "organize" my sage code has been an ongoing issue for me. I have never found a reasonable way to do it for sage notebooks.
posted Mar 17 '11Mike Witt
455 ● 4 ● 11 ● 26
I'm going to repost Felix's comment as my chosen answer, since it could be missed in the comments there:
This works reasonably well for me since I can add my "library" path to the sage path and define sage files there.
posted Mar 21 '11NevilleS
121 ● 2 ● 3 ● 7
Asked: Mar 17 '11
Seen: 236 times
Last updated: Mar 21 '11
powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.