>
> Fails on both Python 2.4 and 2.6 with either ".lib" or "..lib".
>
> ### code
> #!/usr/bin/env python
>
> from ..lib import mymodule
> ####
>
> In python/ddl, referencing ../lib/mymodule.py
>
>  ./import_test.py
> Traceback (most recent call last):
>   File "./import_test.py", line 3, in <module>
>     from .lib import mymodule
> ValueError: Attempted relative import in non-package


The word "package" has a technical meaning.  Here's a description:

    https://docs.python.org/2/tutorial/modules.html#packages

Can you use packages to structure your code directory?  You'll need
"__init__.py" files in the directories that are to be treated as
packages.


If you can structure your program into packages, then intra-package
imports should work:

    https://docs.python.org/2/tutorial/modules.html#intra-package-references
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to