[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [SPAM: 3.500] Re: [pygame] This one baffles me



Greg Ewing wrote:
RB[0] wrote:
Yeah, if you want to convert just the tabs at the start of a line, you would need to do:
print open("myfile.py").read().replace("\n"+" "*4, "\t")

No, that only replaces the first group of 4 spaces on
each line, and removes the newlines as well.

The obvious way to do this properly is to loop over
the lines and use the expandtabs() string method.

Oh, and write a test first....