Ask Your Question
0

Opening .sage files within other files

asked 2012-09-24 02:34:52 +0200

SLOtoSF gravatar image

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:

load /SAGE_ROOT/Project/run.sage.

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 flag offensive close merge delete

Comments

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

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

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-09-25 07:21:13 +0200

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 
load a.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: load b.sage
sage: a
2
sage:
edit flag offensive delete link more

Comments

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.

SLOtoSF gravatar imageSLOtoSF ( 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.

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-09-24 02:34:52 +0200

Seen: 1,034 times

Last updated: Sep 25 '12