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

On 14 August 2012 15:14, Andreas Tawn <andreas.t...@ubisoft.com <mailto:andreas.t...@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"
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to