How to permanently remove __import__?

martin z pxtl at
Tue Jun 17 22:32:35 CEST 2003

Hi - simple problem, but I can't find an answer.  I'm working on an embedded
Python interpreter, and I am overriding the __import__ statement.  This is
for several reasons, but suffice to say I do not want users to be able to
access the traditional __import__ function under any circumstances.  Now, my
problem is this: I can replace __builtins__.__import__ but all the user has
to do is call reload(__builtins__)

I'd just do the same to reload, but reload is a handy function that would be
even messier to re-implement.  That, and I'd always be worried there was
another way to tap into the missing __import__ statement.

More information about the Python-list mailing list