On Fri, Dec 25, 2009 at 07:49:38AM +0100, Fabio Tranchitella wrote:
* 2009-12-25 07:32, Lennart Regebro wrote:
On Thu, Dec 24, 2009 at 14:50, Fabio Tranchitella <kobold@kobold.it> wrote:
I don't think we can avoid the error, and to be honest I consider the code in zope.minmax to be wrong.
""" import zope.testing x = zope.testing.doctest.DocTestFile(... """
The import is wrong
No, that's perferctly correct code and not wrong in any way.
It is not wrong from a syntax point of view, but it is wrong because it assumes doctest is a sub-module and not a sub-package.
I think you mean "assumes doctest is imported in zope.testing's __init__.py". There's no difference between modules or packages for the import statement, witness mg@platonas:~ $ cd tmp mg@platonas:~/tmp $ mkdir a mg@platonas:~/tmp $ touch a/__init__.py mg@platonas:~/tmp $ mkdir a/b mg@platonas:~/tmp $ touch a/b/__init__.py mg@platonas:~/tmp $ touch a/c.py mg@platonas:~/tmp $ python Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import a >>> a.b Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'b' >>> a.c Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'c' >>> Marius Gedminas -- http://pov.lt/ -- Zope 3 consulting and development