Fredrik> s = s.replace("\r", "\n"["\n" in s:])

This fails on admittedly weird strings that mix line endings:

    >>> s = "abc\rdef\r\n"
    >>> s = s.replace("\r", "\n"["\n" in s:])
    >>> s
    'abcdef\n'

where universal newline mode or Just's re.sub() gadget would work.

Skip
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to