Ask Your Question
0

Loading a file unter Windows

asked 2020-03-25 17:53:35 +0100

annegret gravatar image

I am a complete beginner in SageMath. I would like to write a small program in a seperate file and load this into sage. In the German user manual I found the syntax load("beispiel.sage"). But this cannot work, since the program does not know where to look for the file. So I have to tell it the complete path. I tried a lot of different commands, like e.g. load("C:\Users\annegret\Documents\beispiel.sage") or load(`C:\Users\annegret\Documents\beispiel.sage´). I am working unter Windows with the console.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2020-03-25 21:56:16 +0100

Sébastien gravatar image

updated 2020-03-25 21:58:08 +0100

If using a local path, it has to be relative to the present working directory which you can obtain by typing pwd in the sage command line.

sage: pwd

Otherwise, I cannot confirm since I do not have access to a Windows machine, but I would suggest to try to use double backlashes or use raw strings with the small r in front:

sage: load("C:\\Users\\annegret\\Documents\\beispiel.sage")

or

sage: load(r"C:\Users\annegret\Documents\beispiel.sage")

because '\n', '\b', '\U' , '\t' are meant to be characters with special meanings like new lines, tabulations, etc. See this page on Litterals from Python doc for details.

edit flag offensive delete link more

Comments

Thank you. That was helpful. I am now using the relative path to the sage working directory and that works. I use e.g. load("./Documents/test.sage").

annegret gravatar imageannegret ( 2020-03-26 14:32:59 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2020-03-25 17:53:35 +0100

Seen: 266 times

Last updated: Mar 25 '20