how can I run python interactively?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • questions?

    #1

    how can I run python interactively?

    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

  • graham.abbott@gmail.com

    #2
    Re: how can I run python interactively?

    try something like ->

    s = raw_input("Plea se 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.readl ine()

    would be better, note the above requires you to 'import sys'

    Comment

    • Fredrik Lundh

      #3
      Re: how can I run python interactively?

      "questions? " wrote:
      [color=blue]
      > 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.....[/color]

      portable:

      raw_input("plea se press return to continue.....")

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



      http://www.faqts.com/knowledge_base/...d/4490/fid/538
      etc

      </F>



      Comment

      • Graham

        #4
        Re: how can I run python interactively?

        You could use either:

        s = raw_input("Plea se Hit a Key...")

        s being the string they typed before hitting enter.

        or you could use

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

        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?)

        Comment

        • questions?

          #5
          Re: how can I run python interactively?

          Thanks guys for the reply.
          This is very helpful

          Comment

          • Dennis Lee Bieber

            #6
            Re: how can I run python interactively?

            On 2 Nov 2005 22:51:16 -0800, "Graham" <graham.abbott@ gmail.com>
            declaimed the following in comp.lang.pytho n:
            [color=blue]
            >
            > 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?)[/color]

            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.
            --[color=blue]
            > =============== =============== =============== =============== == <
            > wlfraed@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
            > wulfraed@dm.net | Bestiaria Support Staff <
            > =============== =============== =============== =============== == <
            > Home Page: <http://www.dm.net/~wulfraed/> <
            > Overflow Page: <http://wlfraed.home.ne tcom.com/> <[/color]

            Comment

            Working...