A modest proposal

Will Ware wware at world.std.com
Thu Jan 20 12:32:24 EST 2000


Paul M (paul.magwene at yale.edu) wrote:
: Dear Pythoneers...

A great evil has been perpetuated in the design of the Python
language. It grieves me to be the one to bring this to the world's
attention but it must not continue to go unacknowledged. Persons of
right indentation have once again been marginalized and excluded
because _every_editor_ever_written_ indents from the LEFT SIDE OF THE
PAGE. The brutal, systematic, uniform, codified, societally
legitimized vicious assault on right indentation has gone unnoticed,
despite my many pleas to Greenpeace and Amnesty International. I am
forced to bring this issue to the very feet of the Python community
itself, and beg, nay, demand, that the humanity of right-indenters be
recognized and respected. Let the bloodshed end here.

Right-indenters are not a vindictive lot. We do not insist that the
last fifty years of oppression be compensated overnight. We do not
require that CPython's left indentation be removed and replaced with
right indentation. We are a peaceful people, eager for understanding
and amicable coexistence. In the near term, we can get by with the
following script, which translates left indentation to right
indentation.

                            # to-right.py
                   import sys, string, re

              before = re.compile('^\ +')

                               maxlen = 0
                              lines = [ ]
          for L in sys.stdin.readlines():
                           L = L[:-1]
                  if len(L) > maxlen:
                  maxlen = len(L)
                      lines.append(L)

                          for L in lines:
                 s = before.search(L)
                        if s != None:
                 n = s.regs[0][1]
                        L = L[n:]
                                else:
                            n = 0
print (maxlen - n - len(L)) * ' ' + L

As a temporary retrofit, I also offer the left-indented version:

# to-right.py
import sys, string, re

before = re.compile('^\ +')

maxlen = 0
lines = [ ]
for L in sys.stdin.readlines():
    L = L[:-1]
    if len(L) > maxlen:
        maxlen = len(L)
    lines.append(L)

for L in lines:
    s = before.search(L)
    if s != None:
        n = s.regs[0][1]
        L = L[n:]
    else:
        n = 0
    print (maxlen - n - len(L)) * ' ' + L

Right-indenters are a forebearing bunch, and do not instantly
expect a command-line option allowing for right indentation.
We can be gracious enough to wait to see it in Python 2.0.
-- 
   People say that everyone has a few skeletons in their closet. Not me.
   Well, not yet anyway. I mean, the bodies are still decomposing.
Will Ware		email: wware[at]world[dot]std[dot]com



More information about the Python-list mailing list