Reading standard input

Discussion in 'Python' started by MindClass, Oct 28, 2006.

  1. MindClass

    MindClass Guest

    The program shows a license text, then the user has to accept the
    license (or not).
    Is there another way to get text from console? (that using
    sys.stdin.read)

    foo = sys.stdin.read(3)
    if foo != 'yes'
    sys.exit(0)

    I also would to trap the KeyboardInterrupt for that doesn't show that
    message. How would it be possible?
    MindClass, Oct 28, 2006
    #1
    1. Advertising

  2. MindClass wrote:

    > The program shows a license text, then the user has to accept the
    > license (or not).
    > Is there another way to get text from console? (that using
    > sys.stdin.read)


    http://effbot.org/pyref/raw_input.htm

    > I also would to trap the KeyboardInterrupt for that doesn't show that
    > message. How would it be possible?


    any reason you cannot use an ordinary try-except for that?

    </F>
    Fredrik Lundh, Oct 28, 2006
    #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. steve.leach

    How standard is the standard library?

    steve.leach, Apr 18, 2005, in forum: Python
    Replies:
    1
    Views:
    372
    Christos TZOTZIOY Georgiou
    Apr 18, 2005
  2. funkyj
    Replies:
    5
    Views:
    1,106
    funkyj
    Jan 20, 2006
  3. sapsi
    Replies:
    6
    Views:
    503
    John Machin
    May 19, 2008
  4. Yuri Shtil

    Reading from piped standard input on w2k

    Yuri Shtil, Jun 30, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    102
    Tad McClellan
    Jun 30, 2003
  5. Harpreet

    Reading from standard input

    Harpreet, Sep 26, 2006, in forum: Perl Misc
    Replies:
    5
    Views:
    117
    Harpreet
    Sep 29, 2006
Loading...

Share This Page