From: brian z. <bz...@zi...> - 2001-12-13 20:43:56
|
Rasmus, Python's reload() does not work recursively, but this replacement does: http://www.idyll.org/~n8gray/code/files/deep_reload.py brian > -----Original Message----- > From: jyt...@li... > [mailto:jyt...@li...] On Behalf > Of Rasmus Fogh > Sent: Thursday, December 13, 2001 1:01 PM > To: jyt...@li... > Subject: [Jython-users] reload command > > > Dear Jython users, > > If I do module1=reload(module1) and module1 contains the > statement 'import module2', should the reload statement > automatically reload module2? If not, how can I make sure > that all imported modules are reloaded? > > ObjectDomain has embedded Jython in their UML modelling > program, and in their newest version reloading module1 does > *not* reload module2 in this situation. ObjectDomain support > claims that the reason is their recent change from Jython 1.2 > to Jython 2.0, and that *not* reloading mocule2 in the above > situation is correct behaviour. Is this true? > > Thanks for your help, > > Rasmus > > ============================================================== > ============ > > Appendix - Painfully detailed description of the problem follows: > > The system properties are: > Java: IBM corporation, 1.3.0, downloaded bundled with ObjectDomain. > OS: arch x86, Linux, 2.2.17-21mdk > Java Class Version 46.0, compiler jitc > ObjectDomain version 3.00.203 > > > My test files are the following: > > test.py: > import subtest > def dotest(): > print 'Original version' > > subtest.py: > def dosubtest(): > print 'Original subversion' > > > The behaviour observed is: > > Open ObjectDomain > type 'import test' in python shell window. > test.dotest() prints 'Original version' > test.subtest.dosubtest() prints 'Original subversion' > > Now edit test.py and subtest.py to print 'Modified (sub)version' > > Restart python interpreter (green flag icon). > import test.py, either using up-arrow to get the 'import > test' command, > or typing in 'import test' directly. > test.dotest() prints 'Original version' > test.subtest.dosubtest() prints 'Original subversion' > > type 'test = reload(test)' > test.dotest() prints 'Modified version' > test.subtest.dosubtest() prints 'Original subversion' > > > This behaviour means that you are forced to exit and re-enter > the program if you modify a script that is imported through > another script - surely this cannot be the intention. > > -------------------------------------------------------------- > ------------- > Dr. Rasmus H. Fogh Email: r.h...@bi... > Dept. of Biochemistry, University of Cambridge, > 80 Tennis Court Road, Cambridge CB2 1GA, UK. FAX (01223)766002 > > > > > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > |