[Zope] Another import doesn't find the module
Passin, Tom
tpassin@mitretek.org
Wed, 28 May 2003 14:37:42 -0400
[ Dylan Reinhardt]
> That's not how it's *supposed* to work...
>=20
> Your choices (as I recall them) are:
>=20
> from [<package>.]*<module> import <name> [as <new_name>]
>=20
> - or -
>=20
> import [<package>.]*<module> [as <new_name>]
>=20
> Either way, the thing you import or import from should be a module. =20
>=20
No, you can also import names directly from a package - as long as they
are defined in the __init__.py. And you can import a package itself.
Here is working code from my Extensions directory that illustrates the
point. "gcm is a __package__, and "code" is a package nested under
"gcm". gcmdriver is a module in gcm\code.
from gcm.code import gcmdriver
from gcm import BASEPATH
The following also work -
import gcm.code
from gcm import code
Cheers,
Tom P