First time here? Check out the FAQ!

Ask Your Question
0

Opening .sage files within other files

asked 12 years ago

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.

Preview: (hide)

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 ( 12 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 12 years ago

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:
Preview: (hide)
link

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 ( 12 years ago )

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 ( 12 years ago )

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: 12 years ago

Seen: 1,195 times

Last updated: Sep 25 '12