something about split()???

Ramchandra Apte maniandram01 at gmail.com
Tue Aug 14 09:34:17 EDT 2012


(Much) more Pythonic solution:
>>> filter(None,"|".split("|"))

On 14 August 2012 15:14, Andreas Tawn <andreas.tawn at 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120814/de51007d/attachment.html>


More information about the Python-list mailing list