On 4/19/06, Joel Hedlund <[EMAIL PROTECTED]> wrote:
Hi!

From my assign params to attribs script:

# 'onSave' can be added to the list for developing purposes.
if cmd in ['onCreateActions', 'onSave']:
     declare_lots_of_variables_and_stuff

Using 'onSave' in this manner isn't terribly clever, is it?

Say that I delclare a variable and use it in a bunch of places, save and run
and discover an error. Say that in the process of fixing the error I change the
variable, but forget to change it *everywhere*. When I save and retry, the
error may seem to be fixed, because the old value is still in memory and does
not cause a NameError or such until I restart the editor.

Or is there something that I missed?

The reason I added 'onSave' for development is pure laziness. It's quicker to
save-to-update than to restart-to-update. Is there an easy way of provoking an
editor restart in eclipse/pydev, so that the scripting namespace is cleared? As
you already have pointed out, I should take care not to mess around with
globals and to be careful to not use stuff imported to other scripts, but is
there anything else I should do to avoid this pitfall that I seem to fall into
again and again?


Well, currently  there is not a 'reload' scripts, but I guess there's a better way:

...

#the code below can be uncommented when in debug mode to reload things when needed.
#if cmd == 'onSave':
#    from org.python.pydev.jython import JythonPlugin [EMAIL PROTECTED]
#    editor.pyEditScripting.interpreter = JythonPlugin.newPythonInterpreter()
   
if cmd == 'onCreateActions':    
    import re
    from java.lang import StringBuffer
    from org.eclipse.jface.action import Action [EMAIL PROTECTED]
...
 
Or if you feel like doing it, you could probably create a script that recreated the interpreter when requested.

Cheers,

Fabio

Reply via email to