Python style guidelines

Will Berry wberry at wberry.org.x
Thu Mar 11 17:39:31 EST 2004


Style guidelines and coding standards are the devil!  I would enjoy 
nothing more than reading an ACM paper entitled "Coding Standards 
Considered Harmful".  I've never seen a single real-life case where the 
coding standard was anything other than the personal preferences of the 
guy in charge.  No consensus, no objectivity, just consistently 
unreadable code.

I think nothing is more evil about coding standards than indentation. 
My code (not only in Python but in C/C++ and PHP as well) for whatever 
reason always ends up having about 6 levels of indentation in some places.

If the "standard" indentation is anything more than 2 spaces:
     for each little loop or conditional:
         you have to indent more and more until:
             long lines of code (such as calls or complex \
             mathematical expressions) have to span more \
             lines than they would if only the indentation \
             were shorter
else:
     you could simply wrap longer lines and complex \
mathematical formulas without indentation on the remaining \
lines but that just makes your code look like garbage


A close second is my undying hatred for same-line opening braces in C. 
When's the last time you saw Pascal code like:
PROCEDURE This_language_sucks(); BEGIN
   ...
END;

So I hate coding standards eternally, and the ISO 9000 certifiers that 
push them.  They only result in the majority of developers hating to 
write code.  My opinion is that if engineers cannot be trusted to their 
own coding styles, you should have caught that in the interview process 
and not hired them.  Open source projects have probably the best 
argument for coding standards for that reason.  Or, for large projects 
and open source projects, have an auto-styler run on all checked-in 
code.  That would at least do away with the spaces-or-tabs problem.

-- 
Will Berry
Co-founder, Second Brain website hosting
http://www.secondbrainhosting.com/




More information about the Python-list mailing list