• Login
Community
  • Login

[8.6.2] Display live console to work with Python script?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
6 Posts 3 Posters 631 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S
    Shohreh
    last edited by Apr 27, 2024, 3:56 AM

    Hello,

    I’d like to find how to get NppExec to display the output from a Python script in a console within NPP so I don’t need to switch back and forth to Windows’ cmd window.

    Thank you.

    aeae22a0-b20c-4ddc-8a55-d7b9a30fc8dd-image.png

    P E 2 Replies Last reply Apr 27, 2024, 2:06 PM Reply Quote 0
    • P
      PeterJones @Shohreh
      last edited by PeterJones Apr 28, 2024, 1:57 PM Apr 27, 2024, 2:06 PM

      @Shohreh said in [8.6.2] Display live console to work with Python script?:

      Hello,

      I’d like to find how to get NppExec to display the output from a Python script in a console within NPP so I don’t need to switch back and forth to Windows’ cmd window.

      Then congratulations, you have succeeded. The screenshot you included showed it is indeed putting the output into the Book exec console in Notepad++.

      Unfortunately, your Python has an error, so the error is the only output that you see. Try a simple Hello World to see it “work”

      –
      update: sorry, that’s showing my obvious lack of knowledge about exit in Python; see more knowledgeable posts below

      1 Reply Last reply Reply Quote 1
      • E
        Ekopalypse @Shohreh
        last edited by Ekopalypse Apr 27, 2024, 2:33 PM Apr 27, 2024, 2:33 PM

        @Shohreh

        Read about what sys.exit does.
        If interactive mode is required, then use os._exit(WHATEVER_NUMBER) instead.

        S 1 Reply Last reply Apr 27, 2024, 5:11 PM Reply Quote 1
        • S
          Shohreh @Ekopalypse
          last edited by Apr 27, 2024, 5:11 PM

          I also tried quit(), still no output — Can’t post as text since the forum assumes it’s a link.

          The code works fine when ran from a cmd window.

          Too bad.

          82912603-df7e-4909-83b4-855116c39080-image.png

          E 1 Reply Last reply Apr 27, 2024, 5:57 PM Reply Quote 0
          • E
            Ekopalypse @Shohreh
            last edited by Apr 27, 2024, 5:57 PM

            @Shohreh

            but now you have changed the way in which the Python script is executed. In the previous example you executed python directly, now you start a cmd that executes the python script itself.
            As said before, if you want to switch to interactive mode, use os._exit(1) for example, if not, then you can use quit() as long as you understand what it does.

            E 1 Reply Last reply Apr 29, 2024, 6:09 AM Reply Quote 2
            • E
              Ekopalypse @Ekopalypse
              last edited by Apr 29, 2024, 6:09 AM

              @Ekopalypse said in [8.6.2] Display live console to work with Python script?:

              then you can use quit() as long as you understand what it does.

              Correction: this should actually read:

              then you can use exit() as long as you understand what it does.

              1 Reply Last reply Reply Quote 2
              4 out of 6
              • First post
                4/6
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors