[Python-Dev] Unix line endings required for PyRun* breaking
embedded Python
Stuart Bishop
stuart at stuartbishop.net
Fri Jan 21 08:18:59 CET 2005
Just van Rossum wrote:
> Skip Montanaro wrote:
>
>
>>Just re.sub("[\r\n]+", "\n", s) and I think you're good to go.
>
>
> I don't think that in general you want to fold multiple empty lines into
> one. This would be my prefered regex:
>
> s = re.sub(r"\r\n?", "\n", s)
>
> Catches both DOS and old-style Mac line endings. Alternatively, you can
> use s.splitlines():
>
> s = "\n".join(s.splitlines()) + "\n"
>
> This also makes sure the string ends with a \n, which may or may not be
> a good thing, depending on your application.
Do people consider this a bug that should be fixed in Python 2.4.1 and
Python 2.3.6 (if it ever exists), or is the resposibility for doing this
transformation on the application that embeds Python?
--
Stuart Bishop <stuart at stuartbishop.net>
http://www.stuartbishop.net/
More information about the Python-Dev
mailing list