I have to import library which is called functions.sage. How can I do it? I tried:
__import__('functions.sage')
and also this:
import imp
imp.load_source('fun', 'functions.sage')
Edit:
Actually I want to import sage lib into sage. And that lib contains sage-specific code. I tired above variants in sage interpreted. And both gave me ‘no functions module’ or something like this.
Summary: in order to load a function from a
.sagelib insage– one has to parse the.sagefile first – it will make a.pyfile – and thenimportthe.pyfile.Example:
This way the
.sagecode got executed in sage – not in python – as it would be if one will use Sven Marnach’s answer (which is absolutely right – but I stated the question in a wrong way – I forgot to mention that the code’s source has to be executed in python.