469,643 Members | 1,452 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

raw_input

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
1 1915
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.

Similar topics

1 post views Thread by Hugh | last post: by
5 posts views Thread by Helmut Jarausch | last post: by
2 posts views Thread by J. W. McCall | last post: by
reply views Thread by dale | last post: by
21 posts views Thread by planetthoughtful | last post: by
17 posts views Thread by Stuart McGraw | last post: by
8 posts views Thread by Dox33 | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.