Ask Your Question
1

How to load a Python program in Sage Notebook from Menu

asked 11 years ago

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 11 years ago

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

Comments

Thanks for the answer.

Antlab gravatar imageAntlab ( 11 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: 11 years ago

Seen: 1,054 times

Last updated: Jul 24 '13