John Savage wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > >------------------------------- > >whitespace = " " > >old_indent = 3 > >new_indent = 5 > > > >x = " starts with 3 spaces" > > > >x = x.replace(whitespace*old_indent, whitespace*new_indent) > >------------------------------- > > > >In this example though, it will replace the 3 spaces no matter where > >they are at, not just in the beginning... still, it's probably more > >practical for most use cases. > > You'd corner it with: > > if x.startswith(' '*3): x=x.replace(' '*3,' '*5,1)
As others have stated, this will only get lines that start with only 1 set of "old_indent" and not multiples of "old_indent". > -- > John Savage (my news address is not valid for email) -- http://mail.python.org/mailman/listinfo/python-list