RE: [Zope] Another import doesn't find the module
[Stacy Roberts Ladnier]
My Structure has the following -FGDC (directory) - __init__.py - profile.py - DISTRIB.py
The line I had that read from Products.Resources.FGDC import profile failed as you said it should.
However, this line works like a charm: from Products.Resources.FGDC import DISTRIB
BTW, I always interpreted this to mean from <directory> import <module>
Can you explain the *why's* on this one??
An import that fails when the import statement looks perfectly fine is often an indication that there is an error in the module to be imported. It could be a simple indentation error, or something more serious. What is the error message? Import statements import packages, not directories. The __init__.py statement is processed when you import the package, and the modules are processed when you import them from the package. Although most __init__.py files are empty, some code does some really serious work in them I like to use them to store the absolute directory path, which I can use withr elative paths to compute where to put or find files - like this (in the __init__.py ) - import os.path BASEPATH=os.path.dirname(__file__) Then you can import BASEPATH from the package. Cheers, Tom P
participants (1)
-
Passin, Tom