Alternate indent proposal for python 3000

Terry Reedy tjreedy at udel.edu
Sun Apr 20 20:04:22 EDT 2008


"Matthew Woodcraft" <mattheww at chiark.greenend.org.uk> wrote in message 
news:hLC*ZjUas at news.chiark.greenend.org.uk...
| Terry Reedy <tjreedy at udel.edu> wrote:
|
| > But you do not really need a variant.  Just define a preprocessor
| > function 'blockify' which converts code in an alternate syntax to
| > regular indented block syntax.  Then
| >
| > exec(blockify(alt_code_string))
|
| You can do it like that, but if it were to become part of the standard
| distribution it would be nice to avoid having to tokenise the code
| twice.

For the motivating example I was responding to -- short snippets of code in 
html/xml/etc, that is completely a non-issue.

Any such scheme is very unlikely to become part of the stdlib and if it 
were, it would have to first be tested and beat out competitors.  A 
preprocessor written in Python is the obvious way to test and gain 
acceptance.

| (You could define the new block scheme in such a way that
| 'blockify' doesn't need to tokenise,

Off the top of my head: copy C and use {} to demarcate blocks and ';' to 
end statements, so that '\n' is not needed and is just whitespace when 
present.  So, repeatedly scan for the next one of '{};'.

| but I think it would end up a bit ugly.)

For beautiful, stick with standard Python.

Terry Jan Reedy







More information about the Python-list mailing list