[Grok-dev] Re: The Mammoth-Herd Example

Martijn Faassen faassen at startifact.com
Mon Sep 10 16:46:25 EDT 2007

[posted this earlier today but gmane seems to have eaten my mail.
trying again, with a bugfix in my example]


> Perhaps not grok. Something somewhere some months previously pointed to
> a problem where the package and file name are the same. In your case
> 'herd'. I'm not sure that it was grok or even zope3 related but it did
> bite me in a grok application.

f I understand the problem right, it's actually a Python problem (!).
Someone got bit during tutorial I gave at Froscon:

What happens is the following:

package foo
     module foo
         baz = "BAZ"
     module bar
         from foo.foo import baz # fails!
         from foo import baz # works

What happens is that Python's import system does relative imports
first. This means that module bar is not importing package foo as
expected, but module foo instead.

In future versions of Python there's a way to explicitly force an
absolute import, which should solve this problem.



More information about the Grok-dev mailing list