[Zope] Another import doesn't find the module

Dylan Reinhardt zope@dylanreinhardt.com
28 May 2003 11:43:17 -0700


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