2001 Enchancement Wishlist

Thomas Wouters thomas at xs4all.net
Tue Jan 9 07:43:15 EST 2001


On Sat, Jan 06, 2001 at 07:51:35PM +0100, Alex Martelli wrote:
> "Andrew Dalke" <dalke at acm.org> wrote in message
> news:937l3u$gbi$1 at slb2.atl.mindspring.net...
>     [snip]
> >   proxy = Proxy(...)
> >   sys.modules[module_name] = proxy
> >
> > In other words, what you import doesn't need to be a module.
> > It can be a class instance instead - or any other data type.
> 
> Now THAT is interesting!  I would never have guessed that the
> items in sys.modules need not be module objects.  Is this
> documented, something I can rely on forevermore and just
> happened not to notice in my study, or just an accident of the
> current implementation which might go away anytime?

Without pretending to channel Guido or someone similar important in that
area of Python, I think I can safely say it's to be considered an
implementation detail, and that the behaviour is undefined. It could even
be considered a bug, since 'import' claims to import a module into the
local namespace, and a class instance isn't a module :)

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list