Re: [Pydev-code] Use of cmd == 'onSave' bad for development?
Brought to you by:
fabioz
From: Fabio Z. <fa...@gm...> - 2006-04-19 16:24:30
|
On 4/19/06, Joel Hedlund <yo...@if...> 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, th= e > 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 quicke= r > 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 =3D=3D 'onSave': # from org.python.pydev.jython import JythonPlugin #@UnresolvedImport # editor.pyEditScripting.interpreter =3D JythonPlugin.newPythonInterpret= er () if cmd =3D=3D 'onCreateActions': import re from java.lang import StringBuffer from org.eclipse.jface.action import Action #@UnresolvedImport ... Or if you feel like doing it, you could probably create a script that recreated the interpreter when requested. Cheers, Fabio |