I am working on a project to do some computations for a specialized theory. Currently, we have several files that define different objects that have various dependencies on each other. Currently, I have a file named "attachall.sage" that looks like
etc. Then when I want to do some computations, I do
sage: load attachall.sage
sage: #do stuff with the objects
It works fine, I guess, but doesn't seem particularly clean-- it seems like there should be a preferred way to do this. Should I use python's import? But then I would have to re-preparse every time I changed the source, and have potentially annoying bugs if someone forgot to re-preparse after changing a file. Or should I look into making a spkg? I don't really know a lot about that and I'd like to keep it simple.
Eventually we'd like to be able to share this code with other groups.
Does anyone have any thoughts?
I think if the source files are still changing, then staying with
In the meantime, the following will also work to attach all the .sage files in the current directory (although I don't really think it's much better than what you've been doing):
Generally, when you have done larger multi-file projects, it's easier to work directly with Python as opposed to using files that get preparsed. Python just has a better infrastructure for doing these sorts of things. There's not a whole lot of difference -- the whole Sage library is written directly in Python/Cython.
Once you have the code in Python, then you can just create a Python package. There's plenty of documentation on this at http://docs.python.org/distutils/introduction.html. This primarily consists of putting your code in a folder and writing a
If you have a Python package in a directory
posted Mar 02 '11Mike Hansen
3840 ● 21 ● 46 ● 84
Asked: Mar 02 '11
Seen: 305 times
Last updated: Mar 02 '11
powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.