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

Problem capturing output from Python

Expand Messages
  • Peter Anderson
    Hi! I have a problem with EditPlus (E+) capturing output from Python. See the following Python script: # Name: month.py # Purpose: A program to print the
    Message 1 of 1 , Oct 5, 2008
    • 0 Attachment
      Hi! I have a problem with EditPlus (E+) capturing output from Python.
      See the following Python script:

      # Name: month.py
      # Purpose: A program to print the abbreviation of a month, given its number
      # revised to use a list to hold month values rather than a string.
      #

      def main():

      # months is used as a lookup table
      months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
      "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]

      n = input("Enter a month number (1-12): ")

      # print the result
      print "The month abbreviation is", months[n-1] + "."

      if __name__ == '__main__':
      main()

      When I run this script from within E+ using a User Tool (see below) I
      get the following error message in the E+ Output Window:

      ---------- Python ----------
      Enter a month number (1-12): Traceback (most recent call last):
      File "month2.py", line 25, in <module>
      main()
      File "month2.py", line 19, in main
      n = input("Enter a month number (1-12): ")
      EOFError: EOF when reading a line

      Output completed (0 sec consumed)


      If I run the same script in Scite it get:

      >C:\Python25\pythonw -u "month2.py"
      Enter a month number (1-12): 3 <===== Scite pauses here for input
      The month abbreviation is Mar.
      >Exit code: 0


      The configuration of my E+ User Tool is as follows:

      Menu Text: Python
      Command: C:\Python25\pythonw.exe
      Argument: -u "$(FileName)"
      Initial Directory: $(FileDir)
      Capture output: [X]
      Save open files: [X]

      I would like to be able to have E+ function in the same way as Scite;
      i.e. when the script asks for user input then it provides the
      appropriate prompt in the out-put window (or a pop-up window).

      Can anyone please advise if this is possible in E+ and if so how do I
      get it to work. If it's not possible then can I ask for it to be
      considered as a future enhancement.

      Thanks in advance,

      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.