On Dec 17, 2009, at 4:48 AM, Walking Randomly wrote:
> Hi
>
> When in a Sage notebook how do I find what the current working
> directory is and how do I do a directory listing? For example in
> MATLAB I might do
>
> pwd
>
> to print the working directory and
>
> ls
>
> to do a directory listing.
>
> Please accept my apologies if this information is available somewhere
> obvious but I have looked around and can't seem to find a thing.
You can do
sage: os.system('pwd')
sage: os.system('ls')
Note, however, that each notebook cell is executed in its own
directory. Any files that get created in that directory will be shown
(either as an image, or with links at the bottom of the cell output).
If you want to write to files in one cell, and read them from another,
there is a DATA variable that stores a path to a per-worksheet shared
folder, which may be what you want.
- Robert
P.S. Both pwd and ls work fine from the command line.
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org