how to prevent python import from looking into the current directory

Chris Rebert clp2 at rebertia.com
Fri Mar 6 04:39:41 EST 2009


On Fri, Mar 6, 2009 at 1:33 AM, TP <Tribulations at paralleles.invalid> wrote:
> Hi everybody,
>
> I would like to prevent the loading of modules in the current directory.
> For example, if I have a personal module in the current directory
> named "os", when I do "import os", I would like Python to import os
> standard module, not my personal module of the current directory.
> Is this possible?

This should do the trick:

import sys
sys.path.remove('')

Cheers,
Chris

-- 
I have a blog:
http://blog.rebertia.com



More information about the Python-list mailing list