Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #27051
| Date | 2012-08-14 19:09 +0200 |
|---|---|
| From | Jean-Michel Pichavant <jeanmichel@sequans.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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3279.1344964192.4697.python-list@python.org> (permalink) |
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