First time here? Check out the FAQ!

Ask Your Question
1

Running a prewritten program

asked 5 years ago

Schrift gravatar image

In Python you have IDLE, which allows you to write a program and then run it. I am looking for something similar for sage, so that you don't have to type it line for line in sagemath. Is there something that looks like IDLE for sage?

I had a look at this the programmig page of the docs (I cannot post the link due to 'karma' whatever that is), and tried to do it by creating a program in a .txt file and then renaming it to .sage, but sage said that it could not find the file. The error says OSError: did not find file 'C:\Users\Martin\Desktop\example.sage' to load or attach

and the exact thing I wrote is

load("C:\Users\Martin\Desktop\example.sage")

I double checked the path and file name, I am pretty sure that there are no mistakes in that.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 5 years ago

Sébastien gravatar image

updated 5 years ago

See also this other question: https://ask.sagemath.org/question/503... I think you need to write it this way:

sage: load("/Users/Martin/Desktop/example.sage")

or with a relative path:

sage: load("./Desktop/example.sage")
sage: %load ./Desktop/example.sage                           # alternative syntax
sage: %runfile ./Desktop/example.sage                        # alternative syntax

You may also like

sage: attach("./Desktop/example.sage")
sage: %attach ./Desktop/example.sage                         # alternative syntax

which reloads the file automatically on save.

Preview: (hide)
link

Comments

The suggestion load("./Desktop/example.sage") worked, thank you!

Schrift gravatar imageSchrift ( 5 years ago )

I changed @Sébastien's comment to an answer, so that @Schrift can accept it as solving the question.

slelievre gravatar imageslelievre ( 5 years ago )

I wasn't sure since I don't have Windows. But since it seems to work, you are right. Thank you Samuel.

Sébastien gravatar imageSébastien ( 5 years ago )

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 5 years ago

Seen: 284 times

Last updated: May 03 '20