Alternate indent proposal for python 3000

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sun Apr 20 13:29:32 EDT 2008


En Sun, 20 Apr 2008 13:42:05 -0300, Matthew Woodcraft <mattheww at chiark.greenend.org.uk> escribió:

> An alternative scheme for describing the block structure could be
> useful in other cases, though. For example, if you wanted to support
> putting snippets of Python in configuration files, or spreadsheet
> cells.
> [...] If someone wrote a library for this and it proved popular, I expect it
> would be considered for the standard library.

There is "pindent.py" in the Tools/scripts directory:

# ... When called as "pindent -r" it assumes its input is a
# Python program with block-closing comments but with its indentation
# messed up, and outputs a properly indented version.

# A "block-closing comment" is a comment of the form '# end <keyword>'
# where <keyword> is the keyword that opened the block ...

def foobar(a, b):
    if a == b:
        a = a+1
    elif a < b:
        b = b-1
        if b > a: a = a-1
        # end if
    else:
        print 'oops!'
    # end if
# end def foobar

-- 
Gabriel Genellina




More information about the Python-list mailing list