A Python problem?

Charles G Waldman cgw at fnal.gov
Wed Jun 30 22:42:25 CEST 1999


Colin J. Williams writes:
 > def main():
 >   import sys
 >   print 'Start:',dir()
 >   s0= sys.modules
 >   import plugins.rptlib
 >   s1= sys.modules
 >   if s0 == s1:
 >     print 'sys.modules is unchanged'

This will *always* print "sys.modules is unchanged";  sys.modules is a 
dictionary, which is a mutable type.

If you want to see if sys.modules changed, try this:

s0 = sys.modules.copy()
import stuff
if sys.modules == s0:
   print "it's unchanged"




More information about the Python-list mailing list