2001 Enchancement Wishlist
Remco Gerlich
scarblac at pino.selwerd.nl
Tue Jan 9 08:18:58 EST 2001
Thomas Wouters <thomas at xs4all.net> wrote in comp.lang.python:
> 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 :)
And note that you can't use 'from proxy import *' when proxy is a class,
it gives a type error.
This is a pity, since I read this thread and then I wanted to compose some
obfuscated Python in which the entire main loop would be
while 1:
from Perl import *
:-)
--
Remco Gerlich
More information about the Python-list
mailing list