Christoph Zwerschke
unread,Jun 25, 2013, 1:10:27 PM6/25/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to TurboGears Trunk
It sometimes bothers me how often the package name of a TG project is
repeated in a controller module, both in import statements like "from
mylongpackagename.model import MyModelClass" and in expose decorators
like @expose("mylongpackagename.templates.mypage").
So I thought about changing the quickstart templates to use relative
imports, but I found two problems:
1) Relative imports do not work for Genshi (generally dotted notation)
in @expose any more (they used to work in TG1), so we would first need
to add that feature back.
2) I read e.g. in PEP8 that relative imports are considered bad
practice, not only the old implicit relative imports (which is obvious),
but even the newer explicit relative imports. Unfortunately no rationale
is given, I can only guess that it's about "explicit better than
implicit" (since explicit relative imports are only explicit about being
relative, the location is still implicit). I'm not sure whether
"explicit better than implicit" overtrumps DRY here. And I don't
understand why explicit relative imports have been introduced in Python
2 and not been removed from Python 3 if they are really so bad.
Opinions?
-- Christoph