fromNppimport*classB:defblah(self):console.write("I'm b 1\n")
When I run a.py (via N++ Plugins -> Pythonscript -> Scripts -> a.py), it outputs to the console:
I'm a
I'm b 1
HOWEVER, when I make a change to b.py (like attempting to output "I'm b 2" and save it, of course), and then run a.py again, my output doesn't change (still get "I'm b 1"). Why is this?
I find that if I quit N++ and restart it, then my change to b.py gets picked up.
Who out there knows how to avoid this (i.e., how do I make it work "right", where I can just edit+save my files, and have this aspect of things work correctly)?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
from Npp import from b import console.write("I'm a\n")b = B()b.blah()
and a new file called b.py:
from Npp import *class B:
def blah(self):
console.write("I'm b 1\n")
When I run a.py (via N++ Plugins -> Pythonscript -> Scripts -> a.py), it
outputs to the console:
I'm a
I'm b 1
HOWEVER, when I make a change to b.py (like attempting to output "I'm b 2"
and save it, of course), and then run a.py again, my output doesn't change
(still get "I'm b 1"). Why is this?
I find that if I quit N++ and restart it, then my change to b.py gets
picked up.
Who out there knows how to avoid this (i.e., how do I make it work
"right", where I can just edit+save my files, and have this aspect of
things work correctly)?
Strange -- I've been making modifications to my scripts and running them without closing, and it works fine. Where do you have your script saved?
Mine's in the ...\AppData\Roaming\Notepad++\plugins\Config\PythonScript\scripts
directory.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Jacob, I think you're missing the point. The "problem" is not in a main script, but in code that gets imported into the main script.
Dave W, thanks for your input. After doing some reading and experimenting, I think I've decided to just live with this behavior. Code that I am importing is like "library" code anyway, supposedly separately debugged, so there would be no reason to change it when it is imported into something else. That being said, I sometimes find myself adding to the "library" functionality and then getting mildly upset when it isn't brought in without a restart of N++.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Say I create a new pythonscript file, a.py:
and a new file called b.py:
When I run a.py (via N++ Plugins -> Pythonscript -> Scripts -> a.py), it outputs to the console:
HOWEVER, when I make a change to b.py (like attempting to output "I'm b 2" and save it, of course), and then run a.py again, my output doesn't change (still get "I'm b 1"). Why is this?
I find that if I quit N++ and restart it, then my change to b.py gets picked up.
Who out there knows how to avoid this (i.e., how do I make it work "right", where I can just edit+save my files, and have this aspect of things work correctly)?
I seem to remember from "Learning Python", some edition, the part about
"How Python Runs Modules vs. How YOU Run Modules", or such, that modules
imported once and then at some point 'import'ed again, are not actually
re-loaded. You have to run the built-in 'reload' function to actually
accomplish that. I suspect you could just run that from the command line in
PS. Check out the doc...
https://docs.python.org/2/library/functions.html?highlight=reload#reload
vs
https://docs.python.org/2/reference/simple_stmts.html#the-import-statement
Hope this helps.
On Fri, Jun 5, 2015 at 10:48 AM, Sasumner sasumner@users.sf.net wrote:
Strange -- I've been making modifications to my scripts and running them without closing, and it works fine. Where do you have your script saved?
Mine's in the
...\AppData\Roaming\Notepad++\plugins\Config\PythonScript\scripts
directory.
Jacob, I think you're missing the point. The "problem" is not in a main script, but in code that gets imported into the main script.
Dave W, thanks for your input. After doing some reading and experimenting, I think I've decided to just live with this behavior. Code that I am importing is like "library" code anyway, supposedly separately debugged, so there would be no reason to change it when it is imported into something else. That being said, I sometimes find myself adding to the "library" functionality and then getting mildly upset when it isn't brought in without a restart of N++.