Opening .sage files within other files

Hi,

I'm trying to create a project in Sage and ultimately want to run all my .sage files to get things going. So I want to have one run.sage file which I can load from the Sage command line:

This works beautifully if I have all my functions and classes defined in this one file. Ideally I want to have this one file open all my other files so that I can be more modular in my coding.

But this load command doesn't work when it's within a file. Why? I have tried sage_eval and eval.... but it's not working. It tells me it does not recognize the path or something....

Any tips?

Thanks.

edit retag close merge delete

I've not tried such a thing, but you might look at this post for some ideas: http://ask.sagemath.org/question/418/how-to-organize-multifile-project

( 2012-09-24 09:57:59 +0200 )edit

Sort by » oldest newest most voted

You probably don't specify paths to your files right. Here is a simple test showing that one can perfectly use load within another loaded file:

nash:tmp dima$cat a.sage a = 2 nash:tmp dima$ cat b.sage
nash:tmp dima\$ sage
---------------------------------------------
| Sage Version 5.3.beta2, Release Date: 2012-08-16                   |
| Type "notebook()" for the browser-based notebook interface.        |
| Type "help()" for help.                                            |
---------------------------------------------
sage: a
2
sage:

more

yes that's perfect. I'm speaking about the load command within the file though. For example, in "a.sage" above, put the command load b.sage. Then have a file called "b.sage" with b=2.

( 2012-09-27 00:57:26 +0200 )edit

yes that's perfect. I'm speaking about the load command within the file though. For example, in "a.sage" above, put the command load b.sage. Then have a file called "b.sage" with b=2.

( 2012-09-27 00:57:26 +0200 )edit