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


Groups > comp.lang.python > #108022

Re: Best way to clean up list items?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Stephen Hansen <me+python@ixokai.io>
Newsgroups comp.lang.python
Subject Re: Best way to clean up list items?
Date Mon, 02 May 2016 10:25:30 -0700
Lines 15
Message-ID <mailman.325.1462209932.32212.python-list@python.org> (permalink)
References <ng7v9d$ld8$1@dont-email.me> <1462209930.1313497.595817481.73635112@webmail.messagingengine.com>
Mime-Version 1.0
Content-Type text/plain
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de YruoYZOiBkl98oZEzdk0hggxGCJvvFXg90rViuRGUw3g==
Return-Path <me+python@ixokai.io>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'received:internal': 0.09; "','": 0.16; 'dfs': 0.16; 'list1': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:10.202.2.44': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:compute4.internal': 0.16; 'received:io': 0.16; 'received:messagingengine.com': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'have:': 0.18; 'stephen': 0.22; 'am,': 0.23; 'seems': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'subject:list': 0.26; "i'm": 0.30; 'problem': 0.33; 'curious': 0.33; 'point,': 0.33; 'item': 0.35; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'received:66': 0.38; 'to:addr:python.org': 0.40; 'header:Message- Id:1': 0.61; 'generated.': 0.66; 'said:': 0.66; 'want:': 0.84; 'subject:Best': 0.93
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d=ixokai.io; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=NF3lw5YlOh9PjO8JQGOHU37u+8A=; b=q4yeHE JqirtNkpqEbHf9+w/zJhelcFLYvVG+CK62LCrO3Dnvdn2xtATWV+EDDyTyWYQ5L5 6H09oO2mxoyDuKHDaORVgvcFwclTcOJ19MIAZC6Sf2gOLNtsplc4ZZUHOSDNupXI McY4vc2jPLECC+4tBvAvRqmpaisrCSmnPtRpw=
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=NF3lw5YlOh9PjO8 JQGOHU37u+8A=; b=S+VU9MTWmHzd3hyJ9krVYvFbgI41rXSed5PxbUQOk2QByGh 78Fw72CLUGQsJP7hd08iHs4190pBlhXRjl7MaxfKjy6y7o27R7TL21I9IKZBtMiD UJM3Nssmu5PZlj7juLcLHSbqlL6xnClupSFRmXJpkMw3VyLJh0oIuXBwPl1k=
X-Sasl-Enc UrJxcP5QTM19OjqjKYuOUAXDPp7xrOzbMVGyv4i6lIIz 1462209930
X-Mailer MessagingEngine.com Webmail Interface - ajax-491eb5a4
In-Reply-To <ng7v9d$ld8$1@dont-email.me>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <1462209930.1313497.595817481.73635112@webmail.messagingengine.com>
X-Mailman-Original-References <ng7v9d$ld8$1@dont-email.me>
Xref csiph.com comp.lang.python:108022

Show key headers only | View raw


On Mon, May 2, 2016, at 09:33 AM, DFS wrote:
> Have: list1 = ['\r\n   Item 1  ','  Item 2  ','\r\n  ']

I'm curious how you got to this point, it seems like you can solve the
problem in how this is generated.

> Want: list1 = ['Item 1','Item 2']

That said:

list1 = [t.strip() for t in list1 if t and not t.isspace()]

-- 
Stephen Hansen
  m e @ i x o k a i . i o

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Best way to clean up list items? DFS <nospam@dfs.com> - 2016-05-02 12:33 -0400
  Re: Best way to clean up list items? Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-05-02 19:57 +0300
    Re: Best way to clean up list items? justin walters <walters.justin01@gmail.com> - 2016-05-02 10:10 -0700
    Re: Best way to clean up list items? DFS <nospam@dfs.com> - 2016-05-02 14:06 -0400
      Re: Best way to clean up list items? Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-05-02 21:27 +0300
        Re: Best way to clean up list items? DFS <nospam@dfs.com> - 2016-05-02 15:04 -0400
  Re: Best way to clean up list items? Stephen Hansen <me+python@ixokai.io> - 2016-05-02 10:25 -0700
    Re: Best way to clean up list items? DFS <nospam@dfs.com> - 2016-05-02 14:09 -0400
      Re: Best way to clean up list items? Stephen Hansen <me+python@ixokai.io> - 2016-05-02 11:23 -0700
  Re: Best way to clean up list items? Peter Otten <__peter__@web.de> - 2016-05-02 19:30 +0200

csiph-web