Ask Your Question
0

Include own Package

asked 12 years ago

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.

Preview: (hide)

3 Answers

Sort by » oldest newest most voted
1

answered 12 years ago

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

answered 12 years ago

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!

Preview: (hide)
link
0

answered 12 years ago

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.

Preview: (hide)
link

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: 12 years ago

Seen: 1,220 times

Last updated: May 17 '12