Ask Your Question
1

How to load a Python program in Sage Notebook from Menu

asked 2013-07-23 09:28:52 -0500

Antlab gravatar image

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-07-23 18:34:24 -0500

ppurka gravatar image

Use 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 myfunction
edit flag offensive delete link more

Comments

Thanks for the answer.

Antlab gravatar imageAntlab ( 2013-07-24 02:20:59 -0500 )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: 2013-07-23 09:28:52 -0500

Seen: 653 times

Last updated: Jul 23 '13