the indentaion for grouping thing

Don O'Donnell donod at home.com
Sun Jun 24 11:54:56 EDT 2001


Anonymous wrote:
> 
> ...  I gather that someone
> has written a preprocessor that allows you to use delimiters with python.
> Is this true? If so, where can I find it, I would like to use it.
> 

As others have pointed out in past threads, 
you don't need a preprocessor, just use #{ and #}

As in:

    if x > 12: #{
        dosomething()
        #}
    else: #{
        dosomethingelse()
        #}

Although, IMHO, it just adds to the noise and clutter.
Of course, this could also be written as:

    if x > 12:
        #{
        dosomething()
        #}
    else:
        #{
        dosomethingelse()
        #}

Which just points out two more problems with explicit block 
delimiters:
1.  The multitude of coding styles.
2.  The egregious waste of screen space.

I use a Python aware editor, set to use four spaces for tab. 
It automatically indents the lines after 'class', 'def', 'if',
'else', 'while', 'for', etc.  To dedent at the end of a block, 
just hit the backspace key once, it couldn't be simpler, and 
I've never had any of the problems of mixing tabs with spaces 
which you warn against.  

I just can't imagine why anyone would want to fool around with 
opening and closing braces in addition to indenting and dedenting, 
when an editor, configured to recognize Python syntax can make 
life so much easier.

Give it a try for a while, I bet you'll get to like it.

Cheers,
-Don



More information about the Python-list mailing list