On Thu, Dec 17, 2009 at 9:48 PM, Walking Randomly <
[email protected]> wrote:

> Hi both
>
> Thanks for your replies.  It seems to me then that filehandling in the
> Sage notebook is not as intuitive as it could be then.
> Now that you guys have told me about it, I see that the Sage command
> line works exactly as I would expect and I feel instantly at home with
> it.
>
> The notebook interface,however, not so much!  I expect to be able to
> cd, ls, pwd (or Mathematica equivalents) in the notebook just as I
> would in the command line and yet it seems that I can't (easily).
>
> os.listdir(os.getcwd())
>
> looks horrid from a user's point of view IMO.
>
> Best Wishes,
> Mike
>

Hey,

You may also want to try out using

{{{

%sh
cd ~/
ls

}}}

in a cell, which would do what you want. However, if you want to
programatically use the results of these queries, one must use either
os.system('cd') or os.chdir('...'), as these are functions in the Python
library.

Please note that changing directories only affects one cell, for security
reasons.


>
> On Dec 17, 1:09 pm, Minh Nguyen <[email protected]> wrote:
> > Hi Mike,
> >
> > On Thu, Dec 17, 2009 at 11:48 PM, Walking Randomly
> >
> > <[email protected]> wrote:
> > > Hi
> >
> > > When in a Sage notebook how do I find what the current working
> > > directory is
> >
> > Try this:
> >
> > os.getcwd()
> >
> > > and how do I do a directory listing?
> >
> > Try this:
> >
> > os.listdir(os.getcwd())
> >
> > Other operating system services are documented in the Python library
> > reference [1].
> >
> > > For example in
> > > MATLAB I might do
> >
> > > pwd
> >
> > > to print the working directory and
> >
> > > ls
> >
> > > to do a directory listing.
> >
> > You can also do "ls" and "pwd" at the Sage command line interface.
> >
> > [1]http://docs.python.org/library/os.html
> >
> > --
> > Regards
> > Minh Van Nguyen
>
> --
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<sage-support%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/sage-support
> URL: http://www.sagemath.org
>



-- 
Tim Joseph Dumol <tim (at) timdumol (dot) com>
http://timdumol.com

-- 
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

Reply via email to