Ask Your Question

Where is located after I attach walk.sage?

asked 2011-11-17 19:33:17 +0200

rtrwalker gravatar image

updated 2015-01-14 09:43:58 +0200

FrédéricC gravatar image

The sage tutorial Loading and Attaching Sage files states that if I create a file such as walk.sage containing:

print "Hello world"
print 2^4

and then load or attach it:

sage: attach 'walk.sage'
Hello world

I should get a file containing python code in the same directory as walk.sage. I can find no such file (I've even searched my the rest of my computer). Does anyone know where the file is?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2011-11-17 19:50:19 +0200

updated 2011-11-17 20:00:24 +0200

(Edit: I originally thought that there wasn't a file, but I think that's wrong.)

Look in $HOME/.sage/temp/DIR0/DIR1/ where $HOME is your home directory, DIR0 has a name like $HOSTNAME and DIR1 is a number, the process id of the Sage process. This directory is deleted when you quit Sage.

If you want to produce a more permanent file, then from your shell prompt, run sage --preparse walk.sage. This will produce in the current directory.

edit flag offensive delete link more


Nice - that is useful! But of course there is a ;-)

kcrisman gravatar imagekcrisman ( 2011-11-17 20:16:22 +0200 )edit

If my ultimate goal is to write some sort of package, is there any point to me writing *.sage files in the first place or should I start out writing *.py scripts and use "from sage.all import *" and prepend all the sage-functions I use with "sage.all."?

rtrwalker gravatar imagertrwalker ( 2011-11-17 20:17:12 +0200 )edit

Also, I wonder if sometimes it *does* create in the proper directory. At least, I have some .py files I didn't create that are in the same directory as the .sage files I use for my research. But I always have to call them with the full /path/to/file.sage, so maybe that makes a difference as opposed to rtwalker's use case...

kcrisman gravatar imagekcrisman ( 2011-11-17 20:17:50 +0200 )edit

@rtwalker: I think that to start off, the advantage of the .sage files is that you get a quick start and can see what happens. Then when you make .py files out of them, you can later (usually by trial and error) figure out what you actually *need* to important, rather than doing the nasty import * trick. But everyone has a different preferred work flow, it's up to what makes you comfortable and productive.

kcrisman gravatar imagekcrisman ( 2011-11-17 20:19:34 +0200 )edit

@John Palmieri after repeating my procedure I still could not find in the directory that you suggested (all there was was an empty 'interface' directory. Regardless, with your sage --preparse suggestion I can force sage to make me a file. Thanks

rtrwalker gravatar imagertrwalker ( 2011-11-17 20:44:45 +0200 )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


Asked: 2011-11-17 19:33:17 +0200

Seen: 415 times

Last updated: Nov 17 '11