[IronPython] Reloading Modules

Dino Viehland dinov at exchange.microsoft.com
Tue Jan 15 18:40:55 CET 2008


You could always make a 4th module which reloads the 1st three :)

The other option would be to just put them all in one module - that's certainly not unprecedented and if you're not planning on reusing the components/modules individually might make the most sense.

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Pigneri, Rocco
Sent: Tuesday, January 15, 2008 8:23 AM
To: users at lists.ironpython.com
Subject: [IronPython] Reloading Modules

Dear all,

While I know that this could be a more general Python question, since IronPython has its own interpreter, I thought that I should probably ask this question here in case it actually is IPy specific.  Also, I am new to Python so if there is a document somewhere that answers this question, I am more than happy to read it if someone points me to it.

So, the question.  I have a program that has multiple classes.  Since I have a C#/Java background, I have so far put all these classes in a separate file, and thus in a separate module.  They are organized like this:

- Main.py
calls
- ApplicationForm Class
which contains
- Widget Class

Main pretty much just creates a new ApplicatoinForm instance and displays it.  ApplicationForm then has some Widget instances on it.  When I make a change to the Widgets, I find myself reloading the Widget module, then the ApplicationForm module, and then finally Main.py in order to have my changes reflected on the form.  However, I know that this is somewhat against the Python philosophy of dynamic changes while running a program.  Is there a better way to do this, or do I have to use this process because I'm using Windows Forms?  Also, if I do have to continue using this process, is there a quick one-liner that I could use to reload all my changes without having to reload each module by hand?

Thank you,

Rocco
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080115/3bbbedf8/attachment.html>


More information about the Ironpython-users mailing list