[Zope-dev] Coding style clarifications

Zvezdan Petkovic zvezdan at zope.com
Thu Feb 19 10:59:04 EST 2009


> 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?

According to this document in Zope3 developer info (http://wiki.zope.org/zope3/DeveloperInfo 
) it is.

http://svn.zope.org/*checkout*/Sandbox/philikon/foundation/maintaining-software.txt

However, it seems not everybody agrees with that document completely.
:-)

> Import ordering
> ===============
>
> Jim proposed an alternative rule for ordering imports. Is this  
> official?
>
> (My vote is +1 on it)

I like PEP-8 rule with alphabetically sorted groups.

import some-python-module
...

import zope.some-module
...

import myapp.some-module
...

It's consistent with similar import/include rules for other languages  
and large projects.  For example, type "man style" on a Mac or BSD  
computer for BSD kernel style guide.

Having said the above, I personally don't think any of the points  
above are so much important.

For example, a single group of sorted imports (which is I think what  
you refer to) will still form sub-groups internally because of sorting  
(only without empty lines in between).

The one interesting difference is that z3c.something or zc.something  
will sort before zope.something.  Since z3c.something almost certainly  
depends on zope.something that looks a little out of order.

Still, I don't think it's worth arguing over that difference.

Similarly both method_name() and methodName() look fine to me.  One  
could argue that mixedCase() makes public attributes visually distinct  
from local variables (as is suggested in http://wiki.zope.org/zope3/ZopePythonNamingConventions) 
.

So, deviating from PEP-8 in that regard doesn't bother me at all.
OTOH, there's a simplicity in following the PEP-8 single rule for any  
variable/attribute.

Consistency is good on a coarse grain level, but once we start going  
into fine grain details -- whether there's a blank line in between  
sorted import groups or not -- it becomes unproductive.

	Zvezdan



More information about the Zope-Dev mailing list