sys.modules strangeness
Robin Becker
robin at reportlab.com
Thu Apr 29 12:20:13 EDT 2004
A. Lloyd Flanagan wrote:
> Robin Becker <robin at reportlab.com> wrote in message news:<408FF0B1.5090505 at chamonix.reportlab.co.uk>...
>
>>We had some legacy applications that used import to get parts of documents in.
>>When run separately these worked fine, but failed when run as a single process
>>because they both imported ch1 (after jumping to their home dirs and placing
>>these on the path). Clearly the first to run used up ch1.
>
>
> Have you tried reload(ch1)? (see section 2.1, "Built-in Functions",
> in the Python Library Reference.
I know that reload works. I was trying to restore the modules state to a
specific point as in general I didn't know where or which modules the apps could
import.
The original problem has gone away as I decided to exec the code files in a
specific namespace rather than import them. I am still curious why replacing the
current version of sys.modules with an earlier copy doesn't reset the modules list.
--
Robin Becker
More information about the Python-list
mailing list