Re: Re-running script from Tk shell



In article <1177944662.957393.306620@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
gtb <goodTweetieBird@xxxxxxxxxxx> wrote:

I am testing a simple script by running it in the Tk shell. It imports
a class from another module. I edit and save the file from which I
import. When I want to re-run I delete the Tk window and run the
module from the Edit window (F5 - Run Module). The script that does
the importing does not see the changes to the imported class, even if
I delete the compiled files. For it to see the changes I must close
all the edit windows and re-open an Idle edit.

Perhaps I need to de-import the class, but I have not found a method
in the tutorial or the reference (yet).

Try having your script first import the library and then reload it, e.g.:

import foo
reload(foo)

It will load foo more slowly the first time (and a clever if statement
could avoid that) but it will always use the latest foo.

Warning: this will not work if you use
from foo import...

-- Russell
.



Relevant Pages

  • Re: I seek QA for CPerl 5.2 (Emacs mode)
    ... > Editing multi-line quoting constructs goofs fontification until you make ... Moving to the line before the construct and making any edit ...
    (comp.lang.perl.moderated)
  • Re: Editing text strings?
    ... where foo is a text string, and have the Matlab default editor, the ... interactively edit the variable as if it is a .txt file with the ... changes committed by clicking on the "save" button in the editor. ... structure is a text string. ...
    (comp.soft-sys.matlab)
  • Re: Editing text strings?
    ... open foo ... interactively edit the variable as if it is a .txt file with the ... changes committed by clicking on the "save" button in the editor. ... structure is a text string. ...
    (comp.soft-sys.matlab)
  • Re: Mount NTFS drive in Linux
    ... su or sudo. ... I sometimes need to delete files which the Windows user is ... I haven't tried to edit any files. ... [foo]# vi test ...
    (comp.os.linux.misc)
  • Re: What does edit control send to parent window with WM_COMMAND?
    ... If you want the edit control to insert a newline then ES_WANTRETURN will do ... (Enter means push default button). ... when the focus is on the edit window. ... >>> the parent window, ...
    (microsoft.public.win32.programmer.ui)