Re: Importing v reloading modules modules

2010-03-19 Thread Gabriel Genellina
En Fri, 19 Mar 2010 14:09:09 -0300, Peter Peyman Puk escribió: I am running a simulator written in python. The simulator has a small TextView (actually a SourceView) widget which lets the user writes scripts, and when they are satisfied they can execute that script to get results. For ar

Re: Importing v reloading modules modules

2010-03-19 Thread Terry Reedy
Reload is effectively deprecated in 2.x and removed in 3.x, so I recommend not using it. Deleting an entry from sys.modules should force recreation with an import. Just make sure all other references are also gone so that the module object can be deleted. The following shows how to import by

Importing v reloading modules modules

2010-03-19 Thread Peter Peyman Puk
Hello I submitted this earlier today, but I was not clear enough, so I am posting it again. I am running a simulator written in python. The simulator has a small TextView (actually a SourceView) widget which lets the user writes scripts, and when they are satisfied they can execute that s

Re: reloading modules and isinstance()

2007-12-14 Thread Diez B. Roggisch
Tlis schrieb: > Hi, > > I have found that it is possible to reassign the instance.__class__ > reference to the same class (but after reloading) to make the > isinstance() test work again! I know that it is a kind of hacking of > the Python interpreter, but it works :-) It's not especially "hackin

Re: reloading modules and isinstance()

2007-12-14 Thread Tlis
Hi, I have found that it is possible to reassign the instance.__class__ reference to the same class (but after reloading) to make the isinstance() test work again! I know that it is a kind of hacking of the Python interpreter, but it works :-) -- http://mail.python.org/mailman/listinfo/python-lis

Re: reloading modules and isinstance()

2007-12-06 Thread Jean-Paul Calderone
On Thu, 06 Dec 2007 13:59:00 +0100, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > [snip] >> >> Who says it isn't feasible? >> >> http://twistedmatrix.com/trac/browser/trunk/twisted/python/rebuild.py > >Nice try - for sure. But it seems to be geared towards special cases, >not a general-purpose "

Re: reloading modules and isinstance()

2007-12-06 Thread Diez B. Roggisch
Jean-Paul Calderone schrieb: > On Thu, 06 Dec 2007 12:21:01 +0100, "Diez B. Roggisch" > <[EMAIL PROTECTED]> wrote: >> Tlis schrieb: >>> On 5 Dec, 13:18, Steven D'Aprano <[EMAIL PROTECTED] >>> cybersource.com.au> wrote: On Tue, 04 Dec 2007 15:41:48 +0100, Diez B. Roggisch wrote: > You just

Re: reloading modules and isinstance()

2007-12-06 Thread Jean-Paul Calderone
On Thu, 06 Dec 2007 12:21:01 +0100, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >Tlis schrieb: >> On 5 Dec, 13:18, Steven D'Aprano <[EMAIL PROTECTED] >> cybersource.com.au> wrote: >>> On Tue, 04 Dec 2007 15:41:48 +0100, Diez B. Roggisch wrote: You just discovered one reason why reload() is

Re: reloading modules and isinstance()

2007-12-06 Thread Diez B. Roggisch
Tlis schrieb: > On 5 Dec, 13:18, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: >> On Tue, 04 Dec 2007 15:41:48 +0100, Diez B. Roggisch wrote: >>> You just discovered one reason why reload() is a bad idea and IMHO >>> shouldn't be used at all - as tempting it might be. >> I disagre

Re: reloading modules and isinstance()

2007-12-05 Thread Gabriel Genellina
En Wed, 05 Dec 2007 15:06:43 -0300, Tlis <[EMAIL PROTECTED]> escribi�: > With all the problems of the reload() function, I still hope, that > there should be possible to write a safe module 'reloader', that would > fix the references, as required (e.g. by changing the > variable.__class__ referenc

Re: reloading modules and isinstance()

2007-12-05 Thread Chris Mellon
On Dec 5, 2007 12:06 PM, Tlis <[EMAIL PROTECTED]> wrote: > On 5 Dec, 13:18, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: > > On Tue, 04 Dec 2007 15:41:48 +0100, Diez B. Roggisch wrote: > > > You just discovered one reason why reload() is a bad idea and IMHO > > > shouldn't be use

Re: reloading modules and isinstance()

2007-12-05 Thread Tlis
On 5 Dec, 13:18, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Tue, 04 Dec 2007 15:41:48 +0100, Diez B. Roggisch wrote: > > You just discovered one reason why reload() is a bad idea and IMHO > > shouldn't be used at all - as tempting it might be. > > I disagree -- I find reload

Re: reloading modules and isinstance()

2007-12-05 Thread Diez B. Roggisch
Steven D'Aprano wrote: > On Tue, 04 Dec 2007 15:41:48 +0100, Diez B. Roggisch wrote: > >> You just discovered one reason why reload() is a bad idea and IMHO >> shouldn't be used at all - as tempting it might be. > > > I disagree -- I find reload() extremely useful for interactively testing > mo

Re: reloading modules and isinstance()

2007-12-05 Thread Steven D'Aprano
On Tue, 04 Dec 2007 15:41:48 +0100, Diez B. Roggisch wrote: > You just discovered one reason why reload() is a bad idea and IMHO > shouldn't be used at all - as tempting it might be. I disagree -- I find reload() extremely useful for interactively testing modules. But I would never dream of usi

Re: reloading modules and isinstance()

2007-12-04 Thread Diez B. Roggisch
Tlis wrote: > I am using a software system with an embedded Python interpreter > (version 2.3) for scripting. The KcsPoint2D.py module contains a > Point2D class with the following method: > > def SetFromMidpoint(self, p1, p2): >if not isinstance(p1, Point2D) or not isinstance(p2, Point2D): >

reloading modules and isinstance()

2007-12-04 Thread Tlis
I am using a software system with an embedded Python interpreter (version 2.3) for scripting. The KcsPoint2D.py module contains a Point2D class with the following method: def SetFromMidpoint(self, p1, p2): if not isinstance(p1, Point2D) or not isinstance(p2, Point2D): raise TypeError, 'so

Re: reloading modules

2006-12-15 Thread Kent Johnson
Dustan wrote: > [EMAIL PROTECTED] wrote: >> I'm using python.exe to execute my modules. I have a music.py module >> which contains my classes and a main.py module which uses these >> classes. In python.exe, I call "import main" to execute my program. The >> problem is that I have to close python an

Re: reloading modules

2006-12-06 Thread Frank Millman
[EMAIL PROTECTED] wrote: > I'm using python.exe to execute my modules. I have a music.py module > which contains my classes and a main.py module which uses these > classes. In python.exe, I call "import main" to execute my program. The > problem is that I have to close python and reopen it everyti

Re: reloading modules

2006-12-06 Thread Dustan
Dustan wrote: > [EMAIL PROTECTED] wrote: > > I'm using python.exe to execute my modules. I have a music.py module > > which contains my classes and a main.py module which uses these > > classes. In python.exe, I call "import main" to execute my program. The > > problem is that I have to close pyth

Re: reloading modules

2006-12-06 Thread Dustan
[EMAIL PROTECTED] wrote: > I'm using python.exe to execute my modules. I have a music.py module > which contains my classes and a main.py module which uses these > classes. In python.exe, I call "import main" to execute my program. The > problem is that I have to close python and reopen it everytim

reloading modules

2006-12-06 Thread aine_canby
I'm using python.exe to execute my modules. I have a music.py module which contains my classes and a main.py module which uses these classes. In python.exe, I call "import main" to execute my program. The problem is that I have to close python and reopen it everytime i change music.py or main.py. W