Ask Your Question
1

Where is walk.py located after I attach walk.sage?

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

rtrwalker gravatar image

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

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
16

I should get a walk.py 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
1

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

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

(Edit: I originally thought that there wasn't a file walk.py, 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 walk.py, then from your shell prompt, run sage --preparse walk.sage. This will produce walk.py in the current directory.

edit flag offensive delete link more

Comments

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

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

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 +0100 )edit

Also, I wonder if sometimes it *does* create walk.py 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 +0100 )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 +0100 )edit

@John Palmieri after repeating my procedure I still could not find walk.py 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 walk.py file. Thanks

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

Seen: 502 times

Last updated: Nov 17 '11