Community
    • Login

    pythonscript: any ready pyscript to replace one huge set of regex/ phrases with others?

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    58 Posts 10 Posters 19.8k 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.
    • V S RawatV
      V S Rawat @Eko palypse
      last edited by

      @Eko-palypse

      This script will run from within npp and will access net and download all *.py on that page?

      Quite powerful. I never thought such a thing is even possible.

      :-)

      Thanks.

      Eko palypseE 1 Reply Last reply Reply Quote 1
      • Eko palypseE
        Eko palypse @V S Rawat
        last edited by

        @V-S-Rawat

        Yes, but since it does not use any Notepad ++ objects, it can also be run outside of npp.
        The ecosystem of Python is really and I mean really huge.
        If you are thinking about a problem and how you can solve it, there is most likely already a Python module available that is made for it.
        The only little downer is that PythonScript has not implemented pip or it can not be easily implemented (as far as I understand it), which means you have to, if you want to rely on external modules, do some manual work to make it happen within pythonscript plugin.

        V S RawatV 1 Reply Last reply Reply Quote 3
        • V S RawatV
          V S Rawat @Eko palypse
          last edited by

          That brings another bouncer to me.
          @Eko-palypse said:

          Yes, but since it does not use any Notepad ++ objects, it can also be run outside of npp.

          You mean same npp pyscript can be run from outside of npp?

          how? I only have pyscript plugin installed, and it seems it had installed a huge set of files. Are those files sufficient to run npp pyscript from outside npp? How? which exe file to run?

          or do I have to download python afresh and install that to be able to run python out of npp?

          And if so, can I think remove pyscript plugin and still be able to run pyscript from within npp?
          because that would mean one python installed by pyscript within npp, and another python installed directly in programfiles. Why keep both, there may be version clashes between them.

          The ecosystem of Python is really and I mean really huge.
          If you are thinking about a problem and how you can solve it, there is most likely already a Python module available that is made for it.

          yeah, I was also thinking that across the years that python has been popular and widely used, a huge repository of pyscripts must already have been made. But I find very less repositories very less number of scripts then I thought should have been there. Seems I didn’t not reach major pyscript repositories.

          Thanks.

          Eko palypseE Alan KilbornA 2 Replies Last reply Reply Quote 0
          • Eko palypseE
            Eko palypse @V S Rawat
            last edited by

            @V-S-Rawat

            Yes, this particular script may run outside npp if you have a local
            python installation and then by calling python scriptname.py

            Theoretically, you can also uninstall the plugin and remote control
            npp and scintilla with the local python installation.
            But then you have to program everything yourself
            what the pythonscript plugin otherwise provides to you.
            The callbacks could be a bigger challenge.

            A central repo for scripts does not exist, as far as I know,
            but a central system for installing modules does.

            1 Reply Last reply Reply Quote 3
            • Alan KilbornA
              Alan Kilborn @V S Rawat
              last edited by

              @V-S-Rawat

              Just to say a bit more, adding onto what Eko said:

              If you have Pythonscript installed with N++, it is run from a python.dll. If you have no other external Python installed (which would be a python.exe file and of course everything that goes along with it) then you cannot run a .py file outside of N++, even if that .py file isn’t using anything related to N++ (e.g. editor. and notepad. object function calls). Conversely, as pointed out above, you can run such a .py file from inside N++.

              1 Reply Last reply Reply Quote 2
              • Gokul GopalakrishnanG
                Gokul Gopalakrishnan @guy038
                last edited by Gokul Gopalakrishnan

                @guy038 I’m getting this following error when I try to run this script.
                Traceback (most recent call last):
                File “C:\Program Files\Notepad++\plugins\PythonScript\scripts\Samples\Multiples_SR.py”, line 96, in <module>
                (s,r,e) = line[1:].rstrip(‘\n’).split(line[0])
                ValueError: too many values to unpack

                SR_List:
                ‘%(\hpc-nas.noise.server01.net)%(/Volumes)%’,

                M 1 Reply Last reply Reply Quote 1
                • M
                  Mayonnaisu @Gokul Gopalakrishnan
                  last edited by

                  @Gokul-Gopalakrishnan @guy038
                  Me too…

                  EkopalypseE 1 Reply Last reply Reply Quote 0
                  • EkopalypseE
                    Ekopalypse @Mayonnaisu
                    last edited by

                    @Mayonnaisu

                    If you get an error message like ValueError: too many values to unpack, then this is a strong indication that you have generated too many values :-) - I mean, what is wrong with this message?
                    Consider the following: “(a, b) = ‘A B C’.split()”
                    From the code, you expect the split to generate TWO results that you want to put into variables a and b, but that’s not the case, is it?
                    So your real data does not match your code logic.

                    M 1 Reply Last reply Reply Quote 3
                    • M
                      Mayonnaisu @Ekopalypse
                      last edited by

                      @Ekopalypse
                      I see that’s how it is. So I just need to delete the (third) variable that I don’t need. Thanks for the information!

                      EkopalypseE 1 Reply Last reply Reply Quote 0
                      • EkopalypseE
                        Ekopalypse @Mayonnaisu
                        last edited by

                        @Mayonnaisu

                        The error message indicates that you need more variables.
                        If you need less, then the error message would be slightly different, something like need more than 2 values to unpack.

                        M 1 Reply Last reply Reply Quote 1
                        • M
                          Mayonnaisu @Ekopalypse
                          last edited by

                          @Ekopalypse
                          I see… 😅

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post
                          The Community of users of the Notepad++ text editor.
                          Powered by NodeBB | Contributors