Tres Seaver wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Jean-Marc Orliaguet wrote:
There is another place where there seems to be two different patterns too:
sometimes we have:
name = zope.schema.TextLine(...)
from zope.schema import TextLine
name = TextLine(...)
any reason to use one or the other (speed, verbosity, avoiding circular
imports, ...) ?
I vastly prefer the second: it keeps the use points clearer,
I don't know what you mean. Perhaps you are refering to extra
clutter at point of use. I'm sympathetic to this, especially
if something is used a lot.
I generally find the point of use clearer with the full dotted name, or,
for populat modules, like zope.component, zope.schema, etc:
from zope import schema
name = schema.TextLine(...)
I think this is largely a matter of taste.
It is also ever-so-slightly faster, as it avoids a name lookup at
point-of-use. That optimization is the source of only downside of the
practice: it makes monkey-patching harder, because the original binding
I generally only worry about the speed when something is going to be
called a lot, as in a tight loop or in a very popular function. In cases
like those, I do prefer to import the name locally.
Jim Fulton mailto:[EMAIL PROTECTED] Python Powered!
CTO (540) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org
Zope3-dev mailing list