Re: howto load and unload a module

2005-06-24 Thread Guy Robinson
> BTW, question for the OP: what on earth is the use-case for this? Bulk > checking of scripts written by students? > > Cheers, > John I've embedded python in an application which has a .NET API. So users can write scripts in python that access the .NET API. Because of the way the API works r

Re: howto load and unload a module

2005-06-24 Thread Peter Hansen
John Machin wrote: > Peter Hansen wrote: [sample code] > Ummm ... doesn't appear to scale well for multiple modules and multiple > attributes & functions. It certainly wouldn't! :-) I was posting mainly to elicit more information, since clearly you wouldn't get far hardcoding all the names yo

Re: howto load and unload a module

2005-06-24 Thread John Machin
Peter Hansen wrote: > Guy Robinson wrote: > >> I have a directory of python scripts that all (should) contain a >> number of attributes and methods of the same name. >> >> I need to import each module, test for these items and unload the >> module. I have 2 questions. [snip] >> 2.. how do I test

Re: howto load and unload a module

2005-06-24 Thread Peter Hansen
Guy Robinson wrote: > Some of these scripts could potentially be quite large. Also the list of > scripts could be quite large. So the main reason for unloading modules > is to save memory. Unless you're talking megabytes of bytecode (do a "wc *.pyc" on the compiled files and see) it's probably

Re: howto load and unload a module

2005-06-24 Thread Guy Robinson
> > Why would you want to? Doing what you describe doesn't require that you > "unload" a module, unless that means something more to you than, say, > merely releasing the memory used by it (which is likely insignificant to > you). > Hi Peter, I have an application with Python embedded. I'm

Re: howto load and unload a module

2005-06-24 Thread Fuzzyman
Answer to 2 - ``hasattr(module, name)`` -- http://mail.python.org/mailman/listinfo/python-list

Re: howto load and unload a module

2005-06-24 Thread Peter Hansen
Guy Robinson wrote: > I have a directory of python scripts that all (should) contain a number > of attributes and methods of the same name. > > I need to import each module, test for these items and unload the > module. I have 2 questions. > > 1.. How do unload an imported module? Why would yo

howto load and unload a module

2005-06-24 Thread Guy Robinson
Hello, I have a directory of python scripts that all (should) contain a number of attributes and methods of the same name. I need to import each module, test for these items and unload the module. I have 2 questions. 1.. How do unload an imported module? 2.. how do I test for the existance of