| 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
| 2 | No.2 Revision |
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.sagewithcode got executed in sage - not in python.
functions.seq
One can imitate the from functions import seq behaviour with
seq = functions.seq
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.