Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
+1 vote

Happy new year, dear community.

I bother you so early this 2020 with a kind of silly question.

Question: How to import a file with definitions properly?


I have on a folder two files, say header.cnb and calculation.cnb. In the header file I keep a lot of definition of expressions and functions, which will be used in calculation.

I try to import the header as (i.e. in the first lines of calculation)

from header import *

And worked! (hurray), but not always. It seems to depend on whether I open cadabra from the application panel or the CLI... or even worst, it depends on the pwd!

Then I try

import sys
from header import *

and worked!... but again, it stop working on a next session.

Even try:

import os
os.system("cadabra2 /home/oscar/Documents/LatexFiles/UTFSM/Papers/cadabra-gravity/tutorials/header.cnb")


import os
os.system("cadabra2 header.cnb")


import os,sys
scriptpath = "../folder/"
import header
closed with the note: The second try works. The issue raise due to a bad code line in `header`.
asked in General questions by (6.5k points)
closed by