raw_input

Discussion in 'Python' started by Marcello Pietrobon, Apr 20, 2004.

  1. 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
     
    Marcello Pietrobon, Apr 20, 2004
    #1
    1. Advertising

  2. Marcello Pietrobon

    rzed Guest

    Marcello Pietrobon <> wrote in
    news::

    > 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
     
    rzed, Apr 21, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hugh
    Replies:
    1
    Views:
    399
    Dennis Lee Bieber
    Dec 8, 2003
  2. sebb
    Replies:
    2
    Views:
    322
    Serge Orlov
    Jan 13, 2004
  3. Helmut Jarausch

    raw_input - why doesn't prompt go to stderr

    Helmut Jarausch, Jan 26, 2004, in forum: Python
    Replies:
    5
    Views:
    1,279
    Donn Cave
    Jan 28, 2004
  4. Stephen Boulet

    silent raw_input for passwords

    Stephen Boulet, May 1, 2004, in forum: Python
    Replies:
    4
    Views:
    674
    Dominique Orban
    May 2, 2004
  5. Radioactive Man
    Replies:
    4
    Views:
    469
    Radioactive Man
    Sep 20, 2004
Loading...

Share This Page