"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:

> Now it works:
> rex = re.compile(r'(^.*username *=[^"]*")([^"]*)(".*$)')
> for line in fileinput.input(FILE, inplace=1):
>      m = rex.match(line)
>      if m is not None:
>          line = "%s%s%s\n" % (m.group(1), new_name, m.group(3))
>      print line
>
> But there is an extra line break after each line in FILE. Why is that?

Because print prints a newline after all the values you pass it.

> I tried to line = "%s%s%s" % (m.group(1), new_name, m.group(3)) but it
> turns out there are two extra line breaks after each line...

It's not clear what you mean by this. I would have expected this
change to solve the problem. Where do you get two extra newlines?

       <mike
-- 
Mike Meyer <[EMAIL PROTECTED]>                  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to