The very crude solution I use with pure python is to put stuff in the site-packages directory. In sage, this is in $SAGE_ROOT/local/lib/python/site-packages. It is where most python packages install themselves.
-Marshall On Jul 23, 12:11 pm, VictorMiller <[email protected]> wrote: > I know that you can modify sys.path which is where python looks to > find where to use import. The question that I should have asked is > how does one develop new sage functions. It makes sense for each > project to have its own directory to contain the pieces of stuff. > What I'd like is to have some sort of function and/or command for a > SAGE notebook which would give a list of directories to look in when I > do attach or load, so instead of saying > > attach somelongpathstring/foo.sage > > I could just say > > adddirectory somelongpathstring > attach foo.sage > > and foo.sage could have lines like > > from bar import baz > > where bar.py is in the directory somelongpathstring > > Victor > > On Jul 23, 1:56 pm, John Cremona <[email protected]> wrote: > > > Hi Victor. Although I don't know the answer to your question, I'm > > sure that it actually a python question (rather than a sage one) so I > > expect that the answer lies somewhere in the wealth of online python > > documentation! > > > Of course someone else might give a more helpful answer... > > > John Cremona > > > On Jul 23, 5:16 pm, VictorMiller <[email protected]> wrote: > > > > I have a sage program in a file in one of my directories called > > > calc.sage. It uses a class that I wrote called Table, which I've put > > > in a file called Table.py in the same directory. In the sage notebook > > > I load calc.sage (by explicitly giving the path to the directory), and > > > calc.sage has a line > > > > from Table import Table > > > > However, when I try to run it it can't find Table.py. So, the > > > question is, what is the path that sage uses for import, and how do I > > > change it? Is there a way to do this without having to include > > > explicit path qualification in the files? > > > > Victor --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
