ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 27 Sep 2012 00:57:26 +0200Opening .sage files within other fileshttps://ask.sagemath.org/question/9345/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:
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.
Mon, 24 Sep 2012 02:34:52 +0200https://ask.sagemath.org/question/9345/opening-sage-files-within-other-files/Comment by calc314 for <p>Hi,</p>
<p>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: </p>
<p>load /SAGE_ROOT/Project/run.sage.</p>
<p>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. </p>
<p>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....</p>
<p>Any tips? </p>
<p>Thanks.</p>
https://ask.sagemath.org/question/9345/opening-sage-files-within-other-files/?comment=19012#post-id-19012I'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-projectMon, 24 Sep 2012 09:57:59 +0200https://ask.sagemath.org/question/9345/opening-sage-files-within-other-files/?comment=19012#post-id-19012Answer by Dima for <p>Hi,</p>
<p>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: </p>
<p>load /SAGE_ROOT/Project/run.sage.</p>
<p>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. </p>
<p>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....</p>
<p>Any tips? </p>
<p>Thanks.</p>
https://ask.sagemath.org/question/9345/opening-sage-files-within-other-files/?answer=14066#post-id-14066You 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:
Tue, 25 Sep 2012 07:21:13 +0200https://ask.sagemath.org/question/9345/opening-sage-files-within-other-files/?answer=14066#post-id-14066Comment by SLOtoSF for <p>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:</p>
<pre><code>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:
</code></pre>
https://ask.sagemath.org/question/9345/opening-sage-files-within-other-files/?comment=19004#post-id-19004yes 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.Thu, 27 Sep 2012 00:57:26 +0200https://ask.sagemath.org/question/9345/opening-sage-files-within-other-files/?comment=19004#post-id-19004Comment by SLOtoSF for <p>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:</p>
<pre><code>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:
</code></pre>
https://ask.sagemath.org/question/9345/opening-sage-files-within-other-files/?comment=19003#post-id-19003yes 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.Thu, 27 Sep 2012 00:57:26 +0200https://ask.sagemath.org/question/9345/opening-sage-files-within-other-files/?comment=19003#post-id-19003