Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #27051
| 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 | <prvs=5664759f3=jeanmichel@sequans.com> |
| 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 <jeanmichel@sequans.com> |
| User-Agent | Mozilla-Thunderbird 2.0.0.24 (X11/20100328) |
| MIME-Version | 1.0 |
| To | Ramchandra Apte <maniandram01@gmail.com> |
| Subject | Re: something about split()??? |
| References | <CADYZVBDSGb=KL+KgvEG1j1jFnqjKifk6RBJd8C0mKk83rR+_HA@mail.gmail.com> <581D4160B04DF541A763BB8BB60E8CC6A747B70A66@PDC-MAIL-CMS01.ubisoft.org> <CAExgZOh=_Mr0WR4ypXV70s9MUbDHbeppyAq=Nn2yy2NCsws7jQ@mail.gmail.com> |
| In-Reply-To | <CAExgZOh=_Mr0WR4ypXV70s9MUbDHbeppyAq=Nn2yy2NCsws7jQ@mail.gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 8bit |
| Cc | "python-list@python.org" <python-list@python.org>, mingqiang hu <humingqiang5262131@gmail.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3279.1344964192.4697.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
Ramchandra Apte wrote:
> (Much) more Pythonic solution:
> >>> filter(None,"|".split("|"))
>
> On 14 August 2012 15:14, Andreas Tawn <andreas.tawn@ubisoft.com
> <mailto:andreas.tawn@ubisoft.com>> 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"
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: something about split()??? Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-08-14 19:09 +0200
csiph-web