On 6/26/07, Uwe Grauer <[EMAIL PROTECTED]> wrote:
> Ed Leafe wrote:
> > On Jun 26, 2007, at 2:15 PM, johnf wrote:
> >
> >> Python does not care if tabs or spaces are used.  But with respect to
> >> committing to Dabo I would expect only one or the other be used.
> >> Not both.
> >> If memory serves a few months back you and Ed agreed on 'tabs' right?
> >
> >       That was settled several years ago. Tabs work with all fonts,
> > whereas spaces only work with non-proportional fonts.
> >
>
> Even though i don't care, i have a question about this decision:
> Is there a utility which is able to convert a python source file to tabs
> only indentation?

IDLE does it for you.  Open the file, select all, then under the
format menu select tabify region.  There is also an untabify region.

Another opition is to write your own python script.  Here is a quick
little script whipped up.  It assumes you know the number of spaces in
a tab and doesn't have error checking and so on.

def tabify(self, inFile, SpacesInTab):
        file = open(inFile, 'r')
        outputBuffer = []
        
        for line in file:
                numSpaces = len(line) - len(line.lstrip())
                if line.find(" "*numSpaces) == 0:               #Check to see 
if whitespace is
spaces.  If some tabs are included, leave alone
                        line = "\t"*(numSpaces/SpacesInTab) + line.lstrip()
                
                outputBuffer.append(line)
        
        file.close()
        file = open(inFile, 'w')
        file.writelines(outputBuffer)

cheers,

Nate L.

>
>
>
>
>
[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/dabo-dev/[EMAIL PROTECTED]

Reply via email to