restricting import to current package

Robert Roy rjroy at takingcontrol.com
Thu Oct 5 15:12:04 EDT 2000


On Thu, 5 Oct 2000 11:11:32 -0500, "Jeff Kunce"
<kuncej at mail.conservation.state.mo.us> wrote:

>If you say:
>  from mypackage import mymodule
>an ImportError will be raised if mymodule is not found in mypackage.
>
>Is there a way to do something like:
>   from . import mymodule
>In other words:
>  try to import mymodule from the same package (or directory) as this module
>  If mymodule is not there, raise ImportError
>
>Thanks in advance.
>
>  --Jeff
>
>
>
import mymodule

see the tutorial on intrapackage references

Bob



More information about the Python-list mailing list