On Aug 14, 2:23 pm, kj <no.em...@please.post> wrote: > Sometimes I want to split a string into lines, preserving the > end-of-line markers. In Perl this is really easy to do, by splitting > on the beginning-of-line anchor: > > @lines = split /^/, $string; > > But I can't figure out how to do the same thing with Python. E.g.:
Why not this? >>> lines = 'spam\nham\neggs\n'.splitlines (True) >>> lines ['spam\n', 'ham\n', 'eggs\n'] -- http://mail.python.org/mailman/listinfo/python-list