how to prevent python import from looking into the current directory
Christian Heimes
lists at cheimes.de
Fri Mar 6 05:19:39 EST 2009
TP schrieb:
> 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?
Do you have the 'os' module inside your 'personal' package? If you add
from __future__ import absolute_import
then
import os
imports the right 'os' module. With
from . import os
you can import the 'personal.os' module from a module inside 'personal'.
Christian
More information about the Python-list
mailing list