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


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

Re: something about split()???

Started byJean-Michel Pichavant <jeanmichel@sequans.com>
First post2012-08-14 19:09 +0200
Last post2012-08-14 19:09 +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: something about split()??? Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-08-14 19:09 +0200

#27051 — Re: something about split()???

FromJean-Michel Pichavant <jeanmichel@sequans.com>
Date2012-08-14 19:09 +0200
SubjectRe: something about split()???
Message-ID<mailman.3279.1344964192.4697.python-list@python.org>
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"

[toc] | [standalone]


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


csiph-web