Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.028 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'raises': 0.07; 'cc:addr :python-list': 0.10; '"les': 0.16; 'andreas': 0.16; 'function?': 0.16; 'pythonic': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'cheers,': 0.23; 'split': 0.23; 'non': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'cc:addr:gmail.com': 0.27; 'question': 0.27; 'cc:2**2': 0.27; 'url:mailman': 0.29; 'url:python': 0.32; 'url:listinfo': 0.32; 'list': 0.35; 'something': 0.35; 'url:org': 0.36; 'should': 0.36; 'being': 0.37; 'subject:: ': 0.38; 'skip:" 10': 0.40; 'url:mail': 0.40; 'received:194': 0.61; 'more': 0.63; 'august': 0.66; 'low': 0.83 X-IronPort-AV: E=Sophos;i="4.77,768,1336341600"; d="scan'208";a="654282" X-Virus-Scanned: amavisd-new at zimbra.sequans.com Date: Tue, 14 Aug 2012 19:09:50 +0200 From: Jean-Michel Pichavant User-Agent: Mozilla-Thunderbird 2.0.0.24 (X11/20100328) MIME-Version: 1.0 To: Ramchandra Apte Subject: Re: something about split()??? References: <581D4160B04DF541A763BB8BB60E8CC6A747B70A66@PDC-MAIL-CMS01.ubisoft.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Cc: "python-list@python.org" , mingqiang hu X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1344964192 news.xs4all.nl 6878 [2001:888:2000:d::a6]:48468 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27051 Ramchandra Apte wrote: > (Much) more Pythonic solution: > >>> filter(None,"|".split("|")) > > On 14 August 2012 15:14, Andreas Tawn > wrote: > > > I have a question about the split function? surpose a = "|",and > when I use a.split("|") , I got the list > > ['"",""] ,but I want to get the empty list,what should I do ? > > Something like... > > >>> [x for x in "|".split("|") if x] > [] > > Cheers, > > Drea > -- > http://mail.python.org/mailman/listinfo/python-list > > A pythonic answer would be bottom-posted :p JM PS : pylint raises a low warning about *filter* being non pythonic, http://pylint-messages.wikidot.com/messages:w0141 "les goûts et les couleurs ne se discutent pas"