Re: Error when deleting and reimporting subpackages

2011-08-22 Thread John Nagle
On 8/22/2011 11:51 AM, Matthew Brett wrote: Hi, I recently ran into this behavior: import sys import apkg.subpkg del sys.modules['apkg'] import apkg.subpkg as subpkg Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'subpkg' where 'apkg'

Re: Error when deleting and reimporting subpackages

2011-08-22 Thread Stephen Hansen
On Mon, Aug 22, 2011 at 12:14 PM, Matthew Brett wrote: > Yes, sorry, I should have mentioned that I explored these kind of > variations. > > I think I see that there isn't an obvious way for del sys.modules['apkg'] > to know to delete or modify 'apkg.subpkg', because sys.modules is just a > dict.

Re: Error when deleting and reimporting subpackages

2011-08-22 Thread Matthew Brett
On Monday, August 22, 2011 12:06:44 PM UTC-7, Stephen Hansen wrote: > On 8/22/11 11:51 AM, Matthew Brett wrote: > > Hi, > > > > I recently ran into this behavior: > > > import sys > import apkg.subpkg > del sys.modules['apkg'] > import apkg.subpkg as subpkg > > Traceback (most

Re: Error when deleting and reimporting subpackages

2011-08-22 Thread Stephen Hansen
On 8/22/11 11:51 AM, Matthew Brett wrote: > Hi, > > I recently ran into this behavior: > import sys import apkg.subpkg del sys.modules['apkg'] import apkg.subpkg as subpkg > Traceback (most recent call last): > File "", line 1, in > AttributeError: 'module' object has no at

Error when deleting and reimporting subpackages

2011-08-22 Thread Matthew Brett
Hi, I recently ran into this behavior: >>> import sys >>> import apkg.subpkg >>> del sys.modules['apkg'] >>> import apkg.subpkg as subpkg Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'subpkg' where 'apkg' and 'subpkg' comprise empty _