By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,767 Members | 1,332 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,767 IT Pros & Developers. It's quick & easy.

raw_input

P: n/a
Hello,
even if I learned something about Python,
still I don't know how to do ask the input from a user on the command line

This is my ( not working ) code:
if ( not os.path.exists( dirname) ):
msg = 'The directory \'%s\' does not exist. Create it [y/n]
?' % dirname
c = raw_input( msg ).lower
if ( c == 'y' or c == 'yes' ):
os.makedirs( dirname)
else:
raise Exception( 'directory \'%s\' not created,
impossible to continue !' % dirname )
Thank you for any answers,
Marcello

Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Marcello Pietrobon <te*****@attglobal.net> wrote in
news:ma**************************************@pyth on.org:
if ( not os.path.exists( dirname) ):
msg = 'The directory \'%s\' does not exist. Create
it [y/n]
?' % dirname
c = raw_input( msg ).lower
if ( c == 'y' or c == 'yes' ):
os.makedirs( dirname)
else:
raise Exception( 'directory \'%s\' not created,
impossible to continue !' % dirname )


1. lower()(not lower) invokes the method
2. with that change, this code works as expected when I run it form a
win2k command line, from an interactive session, or from Idle.

--
rzed

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.