[Zope-dev] Coding style clarifications
Stephan Richter
srichter at cosmos.phy.tufts.edu
Thu Feb 19 10:46:33 EST 2009
On Thursday 19 February 2009, Christian Theune wrote:
> 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?
Depends on the namespace.ZC has decisively decided to go with underscores, so
all packages in the zc namespace would be like that. The zope and z3c
namespace use camel-case.
> 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.
Well, factories (most often classes) should be capitalized. Sometimes
helper-functions act like classes in that they construct a new objects, then
this rule suggests that it should also be capitalized. I am not sure I like
that, but I can live with it.
All other functions should be mixed case.
> Import ordering
> ===============
>
> Jim proposed an alternative rule for ordering imports. Is this official?
>
> (My vote is +1 on it)
We commonly put import * before from * import *. But otherwise I agree with
that rule and I started doing it this way as well. I have found the PEP8
recommendation hard to follow in certain cases, since it is subjective.
Regards,
Stephan
--
Stephan Richter
Web Software Design, Development and Training
Google me. "Zope Stephan Richter"
More information about the Zope-Dev
mailing list