patching of python: tabs make me seek of python

Andrei Smirnov asmirnov at asmirnov.com
Wed Jan 29 15:25:58 CET 2003


Andrew Bennetts <andrew-pythonlist at puzzling.org> wrote in message news:<mailman.1043799291.30192.python-list at python.org>...
> On Tue, Jan 28, 2003 at 11:43:17AM -0800, Andrei Smirnov wrote:
> > 
> > please, don't try to convince me that tabs are good: i'm too lazy to even think
> > about it. i just want curly braces.
> 
> If you really can't adapt, you can always do:
> 
>     if foo: #{
>         ...
>     #}

this thing i was trying. i guess pindent should have option to generate that,
why not. however xemacs python mode doesn't support #{ #} and things get messy
with time.

> 
> Etc.
> 
> However, I strongly suspect that all you need to do is configure your editor
> correctly, e.g. expand all tabs to spaces, and preferably make sure your
> workmates do the same.

yes, that's good advise. some nonrelevant issues (like my boss is using vi only)
makes it impossible to achive in real life.

my own solutution would be that:
1) adopt modified python syntax:

def main(): {
 print "Hello, world!";
 cond = 1;
 if cond == 0: {
 print "how you get here";
 } else: {
  print "cond is zero";
 }
}

i.e. i'm using ; at the end of each line, { to open block, } to close block.

2) goto in emacs, in c++-mode, mark whole buffer and indent whole buffer (C-M-\)
all emacs keys works!
3) save this program into t.cpy.
4) execute command: sed 's/[;{}]//g' t.cpy > t.py
5) t.py is actual python code

the reason why i'm doing that is simple: using emacs in c++ mode i can
format such code and have all indentation to be redone easily by C-M-\.
then i discard all non-relevant symbols and get equivalent python code
with all indentation done. if i *have to* to copy-and-paste (NOTE: *have to*)
some code segment or decide to include main into some class i dont need to 
anything special: just reindent.

this outlines my proposition: {}; could be discarded in python parser as optional
feature. also it can insert proper amount of spaces instead of doing indent in
emacs.

> 
> -Andrew.

andrei

PS: i like python even more now: all responses was relevant. imagine what if
i would post in perl group proposition to replace curly braces with tabs.




More information about the Python-list mailing list