Gary Poster wrote:
On Nov 21, 2005, at 12:29 PM, Jean-Marc Orliaguet wrote:
There is another place where there seems to be two different patterns
too:
sometimes we have:
import zope.schema
name = zope.schema.TextLine(...)
and sometimes:
from zope.schema import TextLine
name = TextLine(...)
FWIW, a third is
from zope import schema
which I often do for zope.component, zope.interface, zope.event, and
zope.schema.
I'm not weighing in on the style issues.
I like this third style option, import the last module, and then use the
dot notation, and I tend to move towards this pattern in most of my
code. Sometimes of course importing the one class is more convenient.
Rarely do I use the full dot notation.
The benefit of the third option is that it cuts down on your imports and
keeps some namespace information in your code without having to do a lot
of typing nonetheless.
For cases like schema and for instance, hurry.query, there are cases
where the same name in the module is referenced many times in the same
file, and in that case I may be more inclined to import the name
directly without any module prefix.
I don't think using any of these patterns is a big style problem (I'm
much less opinionated about this than about code in __init__.py); it's
hard to recommend a single practice, so perhaps we shouldn't.
Regards,
Martijn
_______________________________________________
Zope3-dev mailing list
[email protected]
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com