Ask Your Question

Importing a sage library???

asked 2012-03-23 03:27:13 -0500

pvl gravatar image

How do I import a sage library? Mine is called functions.sage. But when I import - python says it doesn't know it. I tried:


and also:

import imp
imp.load_source('fun', 'functions.sage')

None works!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2012-03-23 03:47:59 -0500

pvl gravatar image

updated 2012-03-26 01:01:25 -0500

Summary: in order to load a function from a .sage lib in sage - one has to parse the .sage file first - it will make a .py file - and then import the .py file.


import os
os.system(os.curdir + os.sep + 'functions.sage')
from functions import states

This way the .sage code got executed in sage - not in python.

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


Asked: 2012-03-23 03:27:13 -0500

Seen: 206 times

Last updated: Mar 26 '12