how can I run python interactively?

Discussion in 'Python' started by questions?, Nov 3, 2005.

  1. questions?

    questions? Guest

    I need to stop the program in the middle and pause there.

    Are there anyway I can stop the program in the middle and have
    something like:

    please press y to continue.....

    Thanks
    questions?, Nov 3, 2005
    #1
    1. Advertising

  2. questions?

    Guest

    try something like ->

    s = raw_input("Please Press a button...")
    #s is the string they type.

    Although i believe i remember a PEP that said they were removing
    raw_input so perhaps

    print "Please Press A button..."
    s = sys.stdin.readline()

    would be better, note the above requires you to 'import sys'
    , Nov 3, 2005
    #2
    1. Advertising

  3. "questions?" wrote:

    > I need to stop the program in the middle and pause there.
    >
    > Are there anyway I can stop the program in the middle and have
    > something like:
    >
    > please press y to continue.....


    portable:

    raw_input("please press return to continue.....")

    to get a single character, you can use msvcrt.getch() on windows,
    or the termios module on unix:

    http://effbot.org/librarybook/msvcrt.htm
    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/134892
    http://www.faqts.com/knowledge_base/view.phtml/aid/4490/fid/538
    etc

    </F>
    Fredrik Lundh, Nov 3, 2005
    #3
  4. questions?

    Graham Guest

    You could use either:

    s = raw_input("Please Hit a Key...")

    s being the string they typed before hitting enter.

    or you could use

    print "Please hit a key..."
    s = sys.stdin.readline()

    the only reason i recommend the second is because i believe i saw in a
    PEP that raw_input was being depreciated at some point, however i may
    be wrong on that. (correction anyone?)
    Graham, Nov 3, 2005
    #4
  5. questions?

    questions? Guest

    Thanks guys for the reply.
    This is very helpful
    questions?, Nov 3, 2005
    #5
  6. On 2 Nov 2005 22:51:16 -0800, "Graham" <>
    declaimed the following in comp.lang.python:

    >
    > the only reason i recommend the second is because i believe i saw in a
    > PEP that raw_input was being depreciated at some point, however i may
    > be wrong on that. (correction anyone?)


    If anything, I'd expect "input" to be the statement getting the
    axe... After all, it's long been recommended to use raw_input instead of
    input, and /then/ evaluate the data as needed.
    --
    > ============================================================== <
    > | Wulfraed Dennis Lee Bieber KD6MOG <
    > | Bestiaria Support Staff <
    > ============================================================== <
    > Home Page: <http://www.dm.net/~wulfraed/> <
    > Overflow Page: <http://wlfraed.home.netcom.com/> <
    Dennis Lee Bieber, Nov 3, 2005
    #6
    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. Andoni
    Replies:
    0
    Views:
    320
    Andoni
    Apr 26, 2004
  2. Replies:
    4
    Views:
    352
    Michele Simionato
    Apr 26, 2005
  3. terminus
    Replies:
    0
    Views:
    407
    terminus
    Feb 26, 2008
  4. Replies:
    0
    Views:
    268
  5. Cai I.
    Replies:
    6
    Views:
    164
    Cai Inception
    Nov 17, 2010
Loading...

Share This Page