[Zope3-dev] __init__.py interfaces.py guidelines?
Jean-Marc Orliaguet
jmo at ita.chalmers.se
Mon Nov 21 09:52:58 EST 2005
Jim Fulton wrote:
> Jean-Marc Orliaguet wrote:
>
>>
>> OK, so to summarize this thread:
>>
>> - __init__.py files are empty
>>
>> unless for the convenient import of other modules located in the
>> same package or in a subpackage?
>
>
> Actually, primarily for convenient import by external packages.
yes indeed, but no "cross" imports between packages that are siblings.
and in both cases the import is done using absolute paths.
>
>>
>> - public interfaces are stored in interfaces.py
>>
>> - private interfaces are written along with the implementation code
>>
>> - what about file names with an underscore at the beginning? They are
>> used in zope.schema for instance
>
>
> A Python convention is that a leading underscore indicates privateness.
>
but it doesn't inforce it, so another social contract for interfaces like:
"interfaces.py" means "public", otherwise it means "private" might do as
well.
>> - what about import paths inside a same package: relative or absolute?
>>
>> from mypackage.interfaces import ISomeInterface
>> or:
>> from interfaces import ISomeInterface
>
>
> Absolute always. Until the Python import mechanism is fixed, *always*
> use absolute imports.
>
> Jim
>
that's definitely not the way it is currently...
do a:
$ grep -r "from interfaces import" Zope3/src
/JM
More information about the Zope3-dev
mailing list