restricting import to current package

Jeff Kunce kuncej at mail.conservation.state.mo.us
Thu Oct 5 12:11:32 EDT 2000


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






More information about the Python-list mailing list