Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Oh, it got solved it:

functions = imp.new_module("functions")
execfile("functions.sage", vars(functions))

After that one can access a function in there, say seq with

functions.seq

One can imitate the from functions import seq behaviour with

seq = functions.seq

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

Example:

import os
os.system(os.curdir + os.sep + 'functions.sage')
from functions = imp.new_module("functions")
execfile("functions.sage", vars(functions))
import states

After that one can access a function in there, say This way the seq.sage withcode got executed in sage - not in python.

functions.seq

One can imitate the from functions import seq behaviour with

seq = functions.seq