Ask Your Question
0

Include own Package

asked 2012-05-16 23:31:21 +0100

Denis gravatar image

Hi,

I have a very basic question. How can I include my own packages, I.e packages that I wrote myself, into a sage notebook. I am using the notebook environment. So far I have only used Mathematica where I can just load a file filename.m into any notebook.

What is the path were I have to put my own package and what is the format in which I have to save my package (.sws, .sage, py...)? What is the command I have to use to include the file? An example would be very helpful. Again I would like to do everything in the notebook environment.

Thanks for your help.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
0

answered 2012-05-17 16:41:18 +0100

Denis gravatar image

Thanks a lot for your quick replies. I saved my file as a .sage-file and I can load it successfully into my notebook.

Sage is fun!

edit flag offensive delete link more
0

answered 2012-05-17 09:29:08 +0100

Jason Grout gravatar image

Note that the path in the load function could also be a URL, so you can put your file on the web and use it from any notebook. I do this in http://sage.cs.drake.edu/home/pub/66/ to load library files directly from my github repository.

edit flag offensive delete link more
1

answered 2012-05-17 01:58:58 +0100

Shashank gravatar image

You can put your function or class in a .py or .sage file and then run the command. In the following example I have myfunction in file.py

load("/path-to-file/file.py")
myfunction()
edit flag offensive delete link more

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: 2012-05-16 23:31:21 +0100

Seen: 1,131 times

Last updated: May 17 '12