Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #69942 > unrolled thread

Re: is there more simple way to do?

Started byPeter Otten <__peter__@web.de>
First post2014-04-09 12:48 +0200
Last post2014-04-09 12:48 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: is there more simple way to do? Peter Otten <__peter__@web.de> - 2014-04-09 12:48 +0200

#69942 — Re: is there more simple way to do?

FromPeter Otten <__peter__@web.de>
Date2014-04-09 12:48 +0200
SubjectRe: is there more simple way to do?
Message-ID<mailman.9068.1397040606.18130.python-list@python.org>
length power wrote:

> x='name,sex,birthday\n\nx1,male,1948/05/28\n\nx2,female,1952/03/27
> \n\nx3,female,1994/12/09'
> x.replace("\n\n","\n").splitlines()
> 
> is there more simple way to replace  `x.replace("\n\n","\n").splitlines()`
> ?

One alternative that ignores all empty lines is

[line for line in x.splitlines() if line]

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web