TABs (was: Waffling between Python and Ruby)
Darrell Gallion
darrell at dorb.com
Sun Jun 18 16:04:47 EDT 2000
More information about the Python-list mailing list
Sun Jun 18 16:04:47 EDT 2000
- Previous message (by thread): TABs (was: Waffling between Python and Ruby)
- Next message (by thread): TABs (was: Waffling between Python and Ruby)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: "Huaiyu Zhu" <hzhu at mars.localdomain> > >One fairly simple way is to untabify your file, change the tab width, > >and then if you want re-tabify. Emacs will use a mixture of TABs > >(using the new tab width definition) and spaces to achieve the same > >spacing you already have. > > > > This is simple to do for one file, but not for many files. I'd prefer > running something in batch mode on a list of files. > I'm sure there are some better utils floating around, but this one seems to work well for me. import string, sys, glob def main(): tabSize=8 # I start with 8. Starting with 4 will break some files. g=glob.glob(sys.argv[1]) print g a=raw_input('Tabs will be replaced with %d spaces\n Are you sure Y/N:'%tabSize) if not a in ['y','Y']: return for a in g: buf=open(a).read() buf=string.replace(buf,'\t',' '*tabSize) open(a,'w+').write(buf) main() --Darrell
- Previous message (by thread): TABs (was: Waffling between Python and Ruby)
- Next message (by thread): TABs (was: Waffling between Python and Ruby)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list