Loading ...
Sorry, an error occurred while loading the content.
 

Problem with stdin and stdout (I think)

Expand Messages
  • Peter Anderson
    Hello, I m having a problem with EditPlus being used as an IDE for Python scripting. Run the following script from within EditPlus: # password.py pwd =
    Message 1 of 4 , Apr 21, 2009
      Hello,

      I'm having a problem with EditPlus being used as an IDE for Python
      scripting. Run the following script from within EditPlus:

      # password.py
      pwd = input('What is the password? ')
      if pwd == 'apple':
      print('Logging on ...')
      else:
      print('Incorrect password.')
      print('All done!')


      The script fails to complete and produces the following error messages
      in the Output Window:


      ---------- Python 3 ----------
      Traceback (most recent call last):
      File "password.py", line 3, in <module>
      pwd = input('What is the password? ')
      RuntimeError: input(): lost sys.stdin

      Output completed (0 sec consumed)


      If the same script is run from within Scite (open source text editor
      (http://www.scintilla.org/SciTE.html)) it produces the following output:


      >C:\Python30\pythonw -u "password.py"
      What is the password? [cursor sits here waiting for input; type "apple"]
      Logging on ...
      All done!
      >Exit code: 0


      EditPlus can capture any script output from say a print() function but
      does not seem to be able to accept input via an input("...") function.
      Pyscripter (an open source Python IDE
      (http://code.google.com/p/pyscripter/)) has a nice feature where it
      recognises the input() function and pops an input window up, with the
      input() argument as a prompt, for you to type in the input. Very nice!

      Does anyone have any advice on this issue? Is it a limitation on EditPlus?

      Regards,
      Peter
      --
      *Peter Anderson*
      There is nothing more difficult to take in hand, more perilous to
      conduct, or more uncertain in its success, than to take the lead in the
      introduction of a new order of things—Niccolo Machiavelli, /The Prince/,
      ch. 6
    • DZ-Jay
      Hello: EditPlus does not support STDIN when running scripts, as it executes them in a non-interactive shell. It does support capturing of STDOUT and STDERR
      Message 2 of 4 , Apr 22, 2009
        Hello:
        EditPlus does not support STDIN when running scripts, as it executes
        them in a non-interactive shell. It does support capturing of STDOUT
        and STDERR (together) and command-line parameters.

        Sorry,
        dZ.

        --
        // Do something
        marypoppins = ( superman + starship ) / god;

        On Apr 21, 2009, at 20:38, Peter Anderson wrote:

        > Hello,
        >
        > I'm having a problem with EditPlus being used as an IDE for Python
        > scripting. Run the following script from within EditPlus:
        >
        > # password.py
        > pwd = input('What is the password? ')
        > if pwd == 'apple':
        > print('Logging on ...')
        > else:
        > print('Incorrect password.')
        > print('All done!')
        >
        >
        > The script fails to complete and produces the following error messages
        > in the Output Window:
        >
        >
        > ---------- Python 3 ----------
        > Traceback (most recent call last):
        > File "password.py", line 3, in <module>
        > pwd = input('What is the password? ')
        > RuntimeError: input(): lost sys.stdin
        >
        > Output completed (0 sec consumed)
        >
        >
        > If the same script is run from within Scite (open source text editor
        > (http://www.scintilla.org/SciTE.html)) it produces the following
        > output:
        >
        >
        >> C:\Python30\pythonw -u "password.py"
        > What is the password? [cursor sits here waiting for input; type
        > "apple"]
        > Logging on ...
        > All done!
        >> Exit code: 0
        >
        >
        > EditPlus can capture any script output from say a print() function but
        > does not seem to be able to accept input via an input("...") function.
        > Pyscripter (an open source Python IDE
        > (http://code.google.com/p/pyscripter/)) has a nice feature where it
        > recognises the input() function and pops an input window up, with the
        > input() argument as a prompt, for you to type in the input. Very nice!
        >
        > Does anyone have any advice on this issue? Is it a limitation on
        > EditPlus?
        >
        > Regards,
        > Peter
        > --
        > *Peter Anderson*
        > There is nothing more difficult to take in hand, more perilous to
        > conduct, or more uncertain in its success, than to take the lead in
        > the
        > introduction of a new order of things—Niccolo Machiavelli, /The
        > Prince/,
        > ch. 6
        >
        >
        > ------------------------------------
        >
        > http://www.editplus.comYahoo! Groups Links
        >
        >
        >
      • Peter Anderson
        ... Thanks for the feed-back; is there any way that this could be raised as a future enhancement for this great little editor? It would certainly save me a
        Message 3 of 4 , Apr 22, 2009
          DZ-Jay wrote:
          > EditPlus does not support STDIN when running scripts, as it executes
          > them in a non-interactive shell. It does support capturing of STDOUT
          > and STDERR (together) and command-line parameters.
          Thanks for the feed-back; is there any way that this could be raised as
          a future enhancement for this great little editor? It would certainly
          save me a considerable amount of time and effort in switching editors
          just to test run scripts.

          Regards,
          Peter
          --
          *Peter Anderson*
          There is nothing more difficult to take in hand, more perilous to
          conduct, or more uncertain in its success, than to take the lead in the
          introduction of a new order of things—Niccolo Machiavelli, /The Prince/,
          ch. 6
        • Peter Anderson
          ... Necessity is supposed to be the mother of invention so I have developed a *Python specific* work-around: # password.py # This script uses easygui to
          Message 4 of 4 , Apr 22, 2009
            DZ-Jay wrote:
            > EditPlus does not support STDIN when running scripts...
            Necessity is supposed to be the mother of invention so I have developed
            a *Python specific* work-around:


            # password.py
            # This script uses easygui to display a pop-up text entry box
            # easygui is a module for easy GUI programming in Python
            # it uses Tkinter so no other GUI library is required
            # URL: http://easygui.sourceforge.net/

            from easygui import *

            pwd = enterbox(msg='What is the password?', title='password.py',
            default='', strip=True)
            if pwd == 'apple':
            print('Logging on ...')
            else:
            print('Incorrect password.')

            print('All done!')


            That overcomes the problem, but it would be nicer if EditPlus could
            handle STDIN :-)

            By the way, easygui is now Python 3 compatible - a really nice bit of code.

            Regards,
            Peter
            --
            *Peter Anderson*
            There is nothing more difficult to take in hand, more perilous to
            conduct, or more uncertain in its success, than to take the lead in the
            introduction of a new order of things—Niccolo Machiavelli, /The Prince/,
            ch. 6
          Your message has been successfully submitted and would be delivered to recipients shortly.