[Grok-dev] why does grok.formlib use import *?

Brandon Craig Rhodes brandon at rhodesmill.org
Thu Jan 8 13:31:32 EST 2009

I note that grokcore/formlib/__init__.py uses:

from grokcore.component import *
from grokcore.security import *
from grokcore.view import *

which is not only bad for developers trying to read the code (they can't
tell what symbols come from where without reading all of everyone one of
those modules), but also means that lots of symbols are available as
part of "formlib" that might go away later and break developers that
thought that, say, "View" was part of formlib.

Unless there are good reasons for this (was someone imagining doing
"import grokcore.formlib as grok"?), I would like to suggest:

 * We never, ever use "import *"

 * We always, per PEP-8, define "__all__" so that we know precisely what
   symbols we are exporting (and don't get them confused with symbols
   that just happen to be there).

If "import *" is a good idea, I'd still like doing the latter.  It would
be clear to me that (to make as simpler example):

__all__ = ['Form', 'AddForm'] + grok.component.__all__

means "this module is quite deliberately exporting the names Form and
AddForm, *plus* is deliberately creating aliases for everything in

Brandon Craig Rhodes   brandon at rhodesmill.org   http://rhodesmill.org/brandon

More information about the Grok-dev mailing list