Indentation problem

Ben Caradoc-Davies ben at wintersun.org
Mon Mar 25 17:43:36 EST 2002


On Mon, 25 Mar 2002 14:16:49 +0100, Gilles Diribarne <gdiribarne at udcast.com> 
wrote:
> 1/ Because it's almost impossible to paste python code with ident = n 
> spaces to another code with indent = m spaces

"Four was the number of their indenting, and the number of their indenting was
four." -- The Book of Armaments (and the Python Style Guide).

Use automated tools to migrate all your code to four-space indenting.

All coders should conform to

    http://www.python.org/doc/essays/styleguide.html

I was once a two-space indenter, but now I'm Saved.

> This kind of examples occurs more and more and you can indent the code 
> by hand when it's 10 lines of codes, but not 1000 code lines.
> It prevents the re-use of code pieces.

Ack! That's not reuse. That's insanity! Write once and reuse with import. The
Great Satan of software development is code duplication, because all your bugs
are duplicated, as is the work for any redesign. You are doing something wrong.
Abstraction is your only tool to control complexity (other than avoiding
complexity in the first place).

> 2/ Programmers wants independence: some wants to manage building blocks 
> with spaces, other with tabs, some wants length = 4 with tabs.
> I would like to use my own programming style! But, my code risks to be 
> not supported by others.

Your job "risks to be not supported by" your employer. Programmers who want
independence must expect to support their own code, alone.

Frankly, one of the biggest problems preventing code reuse is the mess some
programmers make: other programmers would rather rewrite the code than try to
understand or debug the exisiting code. A consistent style and complete,
correct, in-code documentation (literate programming) helps to encourage reuse.

There's plenty of damage to be done at the higher structural level design/API
without stooping to micro-level style inconsistency.

> 3/ A large number of programming language use this. C, PERL, Ruby, ...
> Why not Python?

Because of crimes committed against legibility by those other languages.

-- 
Ben Caradoc-Davies <ben at wintersun.org>
http://wintersun.org/



More information about the Python-list mailing list