First time here? Check out the FAQ!

Ask Your Question
0

how to create directory named s where s is a string ('mkdir s' will create directory 's')

asked 12 years ago

slelievre gravatar image

How does one create directory named s where s is a string ('mkdir s' will create directory 's'), I want to turn the preparser off in this.

Preview: (hide)

Comments

What about the command cd? How can I change directory to s, where s is a string representing a path?

slelievre gravatar imageslelievre ( 12 years ago )

2 Answers

Sort by » oldest newest most voted
5

answered 12 years ago

DSM gravatar image

updated 12 years ago

You can use os.mkdir (see docs here):

sage: !ls -a 
.  ..
sage: s = "somedirectoryname"
sage: os.mkdir(s)            
sage: !ls -a                 
.  ..  somedirectoryname
Preview: (hide)
link
4

answered 12 years ago

updated 12 years ago

DSM's answer is good. Another option: from within Sage, you can also do

sage: from sage.misc.misc import sage_makedirs
sage: sage_makedirs('/tmp/new/directory/here')

This will create any intermediate directories as necessary. (This function runs os.makedirs(...), along with a little error-checking.)

Re the preparser: to turn it off, just do preparser(False), then execute the command, then turn it back on with preparser(True).

Preview: (hide)
link

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: 12 years ago

Seen: 999 times

Last updated: Aug 21 '12