Re: Problem with Dynamically unloading a module

2010-01-12 Thread Aahz
In article <78388a7a-b148-499a-8894-34e55721e...@k19g2000pro.googlegroups.com>, lordofcode wrote: > >Thanks you all for your replies ,cleared quiet a few doubts about >importing modules and namespace references . >Currently am going with static importing of all modules. But it may >not be efficie

Re: Problem with Dynamically unloading a module

2009-12-24 Thread Lie Ryan
On 12/24/2009 11:51 PM, Jean-Michel Pichavant wrote: But what he *can* do is to learn how importing works. I'm not sure it's terribly helpful to tell somebody all the things they can't do instead of what they can. Hacking python imports would not be in the top of the list of things I would tea

Re: Problem with Dynamically unloading a module

2009-12-24 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Wed, 23 Dec 2009 15:31:53 +0100, Jean-Michel Pichavant wrote: Steven D'Aprano wrote: On Wed, 23 Dec 2009 13:37:06 +0100, Jean-Michel Pichavant wrote: But believe me, you don't want to mess up with the python import mechanism. Unle

Re: Problem with Dynamically unloading a module

2009-12-23 Thread Steve Holden
lordofcode wrote: > Hi All > > Not an expert in Python, so sorry if this sounds like a silly > question. > I went through other few threads in the mailing list but they are not > helping me much. > I have run into a problem related to dynamically loading and unloading > a module. > I need to dynam

Re: Problem with Dynamically unloading a module

2009-12-23 Thread Steven D'Aprano
On Wed, 23 Dec 2009 15:18:10 -0800, Carl Banks wrote: >> > # will unload mod1 assuming mod1 was the only reference to that >> > module. >> >> Which is highly unlikely. Any classes or functions from the module will >> keep the module alive. > > Actually, they won't. Neither classes nor functions

Re: Problem with Dynamically unloading a module

2009-12-23 Thread lordofcode
Hi All, Thanks you all for your replies ,cleared quiet a few doubts about importing modules and namespace references . Currently am going with static importing of all modules. But it may not be efficient in future as the number of interchangeable modules that I have to import may run in 30-40's.(B

Re: Problem with Dynamically unloading a module

2009-12-23 Thread Carl Banks
On Dec 23, 7:40 am, Steven D'Aprano wrote: > On Wed, 23 Dec 2009 13:37:06 +0100, Jean-Michel Pichavant wrote: > > 3/ if you really need to unload the previous module, it's a little bit > > tedious. > > > import mod1 > > del mod1 > > sys.modules['mod1'] = None > > Assigning sys.modules[name] to Non

Re: Problem with Dynamically unloading a module

2009-12-23 Thread Steven D'Aprano
On Wed, 23 Dec 2009 15:31:53 +0100, Jean-Michel Pichavant wrote: > Steven D'Aprano wrote: >> On Wed, 23 Dec 2009 13:37:06 +0100, Jean-Michel Pichavant wrote: >> >> >>> But believe me, you don't want to mess up with the python import >>> mechanism. >>> >>> >> Unless you understand how it

Re: Problem with Dynamically unloading a module

2009-12-23 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Wed, 23 Dec 2009 13:37:06 +0100, Jean-Michel Pichavant wrote: 3/ if you really need to unload the previous module, it's a little bit tedious. import mod1 del mod1 sys.modules['mod1'] = None Assigning sys.modules[name] to None is not the same as deleting the

Re: Problem with Dynamically unloading a module

2009-12-23 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Wed, 23 Dec 2009 13:37:06 +0100, Jean-Michel Pichavant wrote: But believe me, you don't want to mess up with the python import mechanism. Unless you understand how it works. Let me quote the OP: 'Not an expert in Python' I was just answering the OP ques

Re: Problem with Dynamically unloading a module

2009-12-23 Thread Steven D'Aprano
On Wed, 23 Dec 2009 01:41:27 -0800, lordofcode wrote: > I need to dynamically load a module and unload it and load another > module. Why bother unloading it? Unless you're programming for an embedded device, it's highly unlikely that you're so strapped for memory that a module will make any rea

Re: Problem with Dynamically unloading a module

2009-12-23 Thread Steven D'Aprano
On Wed, 23 Dec 2009 13:37:06 +0100, Jean-Michel Pichavant wrote: > 3/ if you really need to unload the previous module, it's a little bit > tedious. > > import mod1 > del mod1 > sys.modules['mod1'] = None Assigning sys.modules[name] to None is not the same as deleting the entry. None has speci

Re: Problem with Dynamically unloading a module

2009-12-23 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: lordofcode wrote: Hi All Not an expert in Python, so sorry if this sounds like a silly question. I went through other few threads in the mailing list but they are not helping me much. I have run into a problem related to dynamically loading and unloading a module. I

Re: Problem with Dynamically unloading a module

2009-12-23 Thread Jean-Michel Pichavant
lordofcode wrote: Hi All Not an expert in Python, so sorry if this sounds like a silly question. I went through other few threads in the mailing list but they are not helping me much. I have run into a problem related to dynamically loading and unloading a module. I need to dynamically load a mo

Re: Problem with Dynamically unloading a module

2009-12-23 Thread Lie Ryan
On 12/23/2009 8:41 PM, lordofcode wrote: Hi All Not an expert in Python, so sorry if this sounds like a silly question. I went through other few threads in the mailing list but they are not helping me much. I have run into a problem related to dynamically loading and unloading a module. I need t