[Zope-dev] Coding style clarifications
Jim Fulton
jim at zope.com
Thu Feb 19 11:03:03 EST 2009
On Feb 19, 2009, at 4:47 AM, Christian Theune wrote:
> Hi,
>
> while gathering, cleaning and consolidating the various statements
> that
> float around about the coding style for Zope 3, I found a couple of
> issues that I'd like to get clarification for.
>
> What I found is currently gathered at
> http://svn.zope.org/zope3docs/source/codingstyle/python-style.rst?rev=96729&view=auto
>
> Which attribute naming is current?
> ==================================
>
> Do we use under_scores or mixedCaseNames?
>
> I think I remember that we decided to follow PEP 8 for new code and
> invoke the "local consistentency" rule on old code. Is that correct?
This is a mess, mainly because PEP 8 changed after an alternative
style had been established in the Zope community. This is complicated
by the fact that many people who work on Zope projects also work on
many non-zope projects.
I only mention this so that readers know the history.
I don't really care much about this issue. Whatever decision is made
is arbitrary.
> Global variable names
> =====================
>
> I don't understand that rule. I kept it around because someone might
> be
> able to explain it more in-depth and whether it still applies.
I don't understand it either. I think it mostly follows established
Python practices which have been changing recently.
I don't care much about this myself.
> Import ordering
> ===============
>
> Jim proposed an alternative rule for ordering imports. Is this
> official?
>
> (My vote is +1 on it)
PEP 8's rule is silly subjective and generally a waste of time. I'm
not going to waste my time following it.
I sort my imports. Period. This makes from imports come before
regular imports (because f comes before i). I discourage from
imports, so this isn't much of an issue for me except for old code.
Having imports sorted takes very little effort and makes imports
easier to find and duplicated easier to spot. Grouping imports makes
imports harder to maintain and read, especially since groupings are
arbitrary unless they follow package boundaries, and just sorting
imports groups imports by package boundaries.
BTW, I strongly discourage from imports. (I didn't always have this
opinion, but have seen the error of my ways. Thanks to Fred Drake for
nudging me in this direction.) IMO, this is wildly more important than
any of the issues raised in this thread.
Jim
--
Jim Fulton
Zope Corporation
More information about the Zope-Dev
mailing list