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?

I'm typically okay with this, though I suspect it can in some cases lead to circular imports you may not otherwise get, and makes finding what's defined harder than if you directly import from the place things are defined. It does make things more convenient however, in some cases.

- public interfaces are stored in interfaces.py

- private interfaces are written along with the implementation code

Right. And point taken from both you and Jim: sometimes you have private interfaces and you don't want to commit to supporting too much API.

- what about file names with an underscore at the beginning? They are used in zope.schema for instance

Hm, if I see a module with an underscore I definitely don't feel very inclined to import *anything* in it from my own code.

I don't use underscore modules a lot in my code, though sometimes if some code is only implementation detail to support some other module, it's not a bad thing to do.

- what about import paths inside a same package: relative or absolute?

   from mypackage.interfaces import ISomeInterface
or:
   from interfaces import ISomeInterface

I prefer absolute. It makes changing the package root harder, but this is not common in practice, and it is much less error-prone in the end as any namespace issues are avoided. If I call my module 'xml' and I do a relative import I may have a problem; I don't want to even think about it :). When Python grows a way to do explicit relative imports then I'll think again.

Thanks for this thread! I hope this information will be put on some web page somewhere eventually.

Regards,

Martijn
_______________________________________________
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to