Ask Your Question

pvl's profile - activity

2020-11-03 23:50:16 +0200 received badge  Popular Question (source)
2020-11-03 23:50:16 +0200 received badge  Notable Question (source)
2012-03-26 08:01:25 +0200 received badge  Editor (source)
2012-03-23 10:01:00 +0200 received badge  Self-Learner (source)
2012-03-23 10:01:00 +0200 received badge  Teacher (source)
2012-03-23 10:00:59 +0200 received badge  Student (source)
2012-03-23 09:47:59 +0200 answered a question Importing a sage library???

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.

Example:

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.

2012-03-23 09:27:13 +0200 asked a question Importing a sage library???

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:

__import__('functions.sage')

and also:

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

None works!