ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 24 Jul 2013 02:20:59 -0500How to load a Python program in Sage Notebook from Menuhttp://ask.sagemath.org/question/10378/how-to-load-a-python-program-in-sage-notebook-from-menu/Hi all,
I would like to know if is it possible from the graphical menu of the Sage notebook to insert a program in Python written in an external editor (as Spyder) inside a cell of the notebook.
I tried with Data->Upload, but I did not understand how it works.
I know that it is possible to directly use the command "load(program)", but it is not too comfortable, requiring to write the whole path of the file.
Thanks.Tue, 23 Jul 2013 09:28:52 -0500http://ask.sagemath.org/question/10378/how-to-load-a-python-program-in-sage-notebook-from-menu/Answer by ppurka for <p>Hi all,
I would like to know if is it possible from the graphical menu of the Sage notebook to insert a program in Python written in an external editor (as Spyder) inside a cell of the notebook.
I tried with Data->Upload, but I did not understand how it works.
I know that it is possible to directly use the command "load(program)", but it is not too comfortable, requiring to write the whole path of the file.
Thanks.</p>
http://ask.sagemath.org/question/10378/how-to-load-a-python-program-in-sage-notebook-from-menu/?answer=15272#post-id-15272Use Data -> Upload to upload your python file, say, `myfile.py`. Then, in a cell, type
load(DATA + 'myfile.py')
This will load your python file. If you want to only import certain objects then you can write the following in a cell
os.environ['PYTHONPATH'] += DATA
from myfile import myfunctionTue, 23 Jul 2013 18:34:24 -0500http://ask.sagemath.org/question/10378/how-to-load-a-python-program-in-sage-notebook-from-menu/?answer=15272#post-id-15272Comment by Antlab for <p>Use Data -> Upload to upload your python file, say, <code>myfile.py</code>. Then, in a cell, type</p>
<pre><code>load(DATA + 'myfile.py')
</code></pre>
<p>This will load your python file. If you want to only import certain objects then you can write the following in a cell</p>
<pre><code>os.environ['PYTHONPATH'] += DATA
from myfile import myfunction
</code></pre>
http://ask.sagemath.org/question/10378/how-to-load-a-python-program-in-sage-notebook-from-menu/?comment=17247#post-id-17247Thanks for the answer.
Wed, 24 Jul 2013 02:20:59 -0500http://ask.sagemath.org/question/10378/how-to-load-a-python-program-in-sage-notebook-from-menu/?comment=17247#post-id-17247