Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: something about split()???

Thread Tools

Re: something about split()???

Jean-Michel Pichavant
Posts: n/a
Ramchandra Apte wrote:
> (Much) more Pythonic solution:
> >>> filter(None,"|".split("|"))

> On 14 August 2012 15:14, Andreas Tawn <(E-Mail Removed)
> <(E-Mail Removed)>> 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
> --

A pythonic answer would be bottom-posted


PS : pylint raises a low warning about *filter* being non pythonic,
"les goûts et les couleurs ne se discutent pas"
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
XPath query for <?define something="something" ?> Pekka Järvinen XML 2 04-29-2008 08:12 PM
How to find and replace something that is nested inside something else? Perl Misc 4 05-31-2007 11:50 PM
var Something= new Something() What does it mean ? Javascript 9 10-05-2006 02:43 PM
Etching tutorials-or now for something completely different Technoholic Case Modding 71 09-27-2005 06:39 AM
umm... something... template(s)... something else... pointer(s)... and such... 0.o yah, I'm hopeless and clueless o.0 C++ 4 10-13-2004 10:34 PM