re.match oddity
Issac
issac at myfirstlink.net
Wed Dec 26 19:11:58 EST 2001
I'll give that a try. Thanks for your help.
Issac
----- Original Message -----
From: "Hans Nowak" <wurmy at earthlink.net>
Newsgroups: comp.lang.python
To: <python-list at python.org>
Sent: Wednesday, December 26, 2001 6:42 PM
Subject: Re: re.match oddity
> Issac wrote:
> >
> > A curious thing is happening in my c2py.py script (below).
> > The resulting files contain little ^M's (when viewed with the Windows
> > version of gvim 6.0 but not when viewed with notepad.exe) at the ends
> > of the lines. When I remove the lines
> >
> > line_is_lone_left_curly = re.match(r'^\s*{\s*((//.*)|(/\*.*\*/))?$', line)
> > if line_is_lone_left_curly:
> > pylines[-1] = pylines[-1][:-1] + ':\n'
> > continue
> >
> > the ^M's go away. Does anyone know why? I'm using Python 2.1.1
> > on Cygwin with Windows 2000.
>
> Not sure it has anything to do with re.match. Most likely it's caused
> by the line that appends ':\n'. This is probably written to file
> as '\r\n' (CR/LF) (in Windows). I suspect that some other lines
> only have '\n' (LF) as a line separator, otherwise gvim would not show
> them; it usually detects the line ending and displays the text
> accordingly.
>
> The solution is to make sure that your lines have either a Windows
> or a Unix line ending, but not a mix. Use os.linesep when in doubt.
>
> --Hans
> --
> http://mail.python.org/mailman/listinfo/python-list
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.310 / Virus Database: 171 - Release Date: 12/19/2001
More information about the Python-list
mailing list