Re: [Zope] Another import doesn't find the module
First, I realized I did not need profile.py so I removed that line of code. What you say about not importing directories makes sense. However the following doesn't: 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?? Even though I can move forward with my coding, my mind is still stuck on why this is? Thanks, Stacy ----- Original Message ----- From: Dylan Reinhardt <zope@dylanreinhardt.com> Date: Wednesday, May 28, 2003 1:01 pm Subject: Re: [Zope] Another import doesn't find the module
Go back and look a little closer at the difference between what I typedand what you're using.
Both your examples attempt to import from directories, something you simply can't do... at least not *this* way. In Python, the word "module" refers, typically, to a .py file. You can't find a module called FGDC because (according to your diagram) there isn't one.
Once you re-work import to import names from modules, I think you'll have better luck.
HTH,
Dylan
On Wed, 2003-05-28 at 10:06, Stacy Roberts Ladnier wrote:
I have tried both. The name of the class I am trying to import is profile. So I put from Products.Resources.FGDC import profile and I get 'cannot import name profile'
When I try from Products.Resources.FGDC import * I get 'no module named FGDC'. But I promise there is and there is a __init__ file there this time. This module is used from many other parts in my product.
I have the PYTHONPATH right and an __init__ in both the FGDC and extensions folders. I am at a loss for what is happening here.
Any help is appreciated, this is the last task before deployment.
Stacy
----- Original Message ----- From: Dylan Reinhardt <zope@dylanreinhardt.com> Date: Wednesday, May 28, 2003 10:38 am Subject: Re: [Zope] Another import doesn't find the module
This is a different problem. I think what you want is:
import * from Products.Resources.FGDC.profile
or
from Products.Resources.FGDC.profile import NAMES_GO_HERE
HTH,
Dylan
On Wed, 2003-05-28 at 07:33, Stacy Roberts Ladnier wrote:
I am attempting to import another class for use and Zope now complains 'cannot import name profile'.
My Product structure in a bit more detail is:
Products - Resources -FGDC -__init__.py -profile.py -BIO -scripts -script1.py -dtml -www -extensions -DISTINFO.py which contains a class of the same name
In DISTINFO.py, I have an import statement like this: from Products.Resources.FGDC import profile
Can someone please tell me what I am doing wrong here??
Thanks in advance, Stacy
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
On Wed, 2003-05-28 at 10:48, Stacy Roberts Ladnier wrote:
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.
OK.
However, this line works like a charm: from Products.Resources.FGDC import DISTRIB
Uh...? By "works like a charm" do you mean that you don't get any errors? Or are you actually able to use names from DISTRIB?
BTW, I always interpreted this to mean from <directory> import <module>
That's not how it's *supposed* to work... Your choices (as I recall them) are: from [<package>.]*<module> import <name> [as <new_name>] - or - import [<package>.]*<module> [as <new_name>] Either way, the thing you import or import from should be a module.
Can you explain the *why's* on this one?? Even though I can move forward with my coding, my mind is still stuck on why this is?
I'm not sure, frankly, why the from...import you've got for DISTRIB works... but I'm pretty sure that it shouldn't. Could be I'm missing something obvious and/or obscure. This might be a good question for the gurus over at c.l.python. Dylan
participants (2)
-
Dylan Reinhardt -
Stacy Roberts Ladnier