Re: a splitting headache

2009-10-26 Thread jhermann
On 16 Okt., 02:18, Mensanator mensana...@aol.com wrote: All I wanted to do is split a binary number into two lists, a list of blocks of consecutive ones and another list of blocks of consecutive zeroes. Back to the OP's problem, the obvious (if you know the std lib) and easy solution is: c =

Re: a splitting headache

2009-10-26 Thread Vlastimil Brom
2009/10/26 jhermann juergen.herm...@1und1.de: On 16 Okt., 02:18, Mensanator mensana...@aol.com wrote: All I wanted to do is split a binary number into two lists, a list of blocks of consecutive ones and another list of blocks of consecutive zeroes. Back to the OP's problem, the obvious (if

Re: a splitting headache

2009-10-26 Thread Mensanator
On Oct 26, 7:28 am, Vlastimil Brom vlastimil.b...@gmail.com wrote: 2009/10/26 jhermann juergen.herm...@1und1.de: On 16 Okt., 02:18, Mensanator mensana...@aol.com wrote: All I wanted to do is split a binary number into two lists, a list of blocks of consecutive ones and another list of

Re: a splitting headache

2009-10-23 Thread Paul Rudin
Mensanator mensana...@aol.com writes: No one ever considers making life easy for the user. That's a bizarre assertion. -- http://mail.python.org/mailman/listinfo/python-list

Re: a splitting headache

2009-10-23 Thread Mensanator
On Oct 22, 1:22 pm, Paul Rudin paul.nos...@rudin.co.uk wrote: Mensanator mensana...@aol.com writes: No one ever considers making life easy for the user. That's a bizarre assertion. I have a bad habit of doing that. -- http://mail.python.org/mailman/listinfo/python-list

Re: a splitting headache

2009-10-23 Thread Mensanator
On Oct 22, 2:23 pm, Falcolas garri...@gmail.com wrote: On Oct 22, 11:56 am, Mensanator mensana...@aol.com wrote: [massive snip] Yes, AFTER you read the docs. Not to feed the troll, I prefer the term gadfly. but obligatory reference to XKCD: http://xkcd.com/293/ --

Re: a splitting headache

2009-10-22 Thread rurpy
On 10/21/2009 11:47 PM, Carl Banks wrote: On Oct 21, 12:46 pm, David C Ullrich dullr...@sprynet.com wrote: On Tue, 20 Oct 2009 15:22:55 -0700, Mensanator wrote: On Oct 20, 1:51 pm, David C Ullrich dullr...@sprynet.com wrote: I'm not saying either behaviour is wrong, it's just not obvious

Re: a splitting headache

2009-10-22 Thread Mensanator
On Oct 21, 11:21�pm, John Yeung gallium.arsen...@gmail.com wrote: On Oct 21, 5:43�pm, Mensanator mensana...@aol.com wrote: '01110'.split('0') ['', '1', '', '', '', '11', ''] is a perfect example. It shows the empty strings generated from the leading and trailing delimiters, and

Re: a splitting headache

2009-10-22 Thread Mensanator
On Oct 22, 1:13�am, ru...@yahoo.com wrote: On 10/21/2009 11:47 PM, Carl Banks wrote: On Oct 21, 12:46 pm, David C Ullrich dullr...@sprynet.com wrote: On Tue, 20 Oct 2009 15:22:55 -0700, Mensanator wrote: On Oct 20, 1:51 pm, David C Ullrich dullr...@sprynet.com wrote: I'm not saying

Re: a splitting headache

2009-10-22 Thread David C . Ullrich
On Wed, 21 Oct 2009 22:47:24 -0700 (PDT), Carl Banks pavlovevide...@gmail.com wrote: On Oct 21, 12:46 pm, David C Ullrich dullr...@sprynet.com wrote: On Tue, 20 Oct 2009 15:22:55 -0700, Mensanator wrote: On Oct 20, 1:51 pm, David C Ullrich dullr...@sprynet.com wrote: I'm not saying either

Re: a splitting headache

2009-10-22 Thread David C . Ullrich
On Wed, 21 Oct 2009 14:43:48 -0700 (PDT), Mensanator mensana...@aol.com wrote: On Oct 21, 2:46 pm, David C Ullrich dullr...@sprynet.com wrote: On Tue, 20 Oct 2009 15:22:55 -0700, Mensanator wrote: On Oct 20, 1:51 pm, David C Ullrich dullr...@sprynet.com wrote: On Thu, 15 Oct 2009 18:18:09

Re: a splitting headache

2009-10-22 Thread Mensanator
On Oct 22, 7:47�am, David C. Ullrich dullr...@sprynet.com wrote: On Wed, 21 Oct 2009 14:43:48 -0700 (PDT), Mensanator mensana...@aol.com wrote: On Oct 21, 2:46�pm, David C Ullrich dullr...@sprynet.com wrote: On Tue, 20 Oct 2009 15:22:55 -0700, Mensanator wrote: On Oct 20, 1:51�pm,

Re: a splitting headache

2009-10-22 Thread David C . Ullrich
On Wed, 21 Oct 2009 14:43:48 -0700 (PDT), Mensanator mensana...@aol.com wrote: On Oct 21, 2:46 pm, David C Ullrich dullr...@sprynet.com wrote: On Tue, 20 Oct 2009 15:22:55 -0700, Mensanator wrote: On Oct 20, 1:51 pm, David C Ullrich dullr...@sprynet.com wrote: On Thu, 15 Oct 2009 18:18:09

Re: a splitting headache

2009-10-22 Thread John Posner
Carl Banks wrote: snip s.split() and s.split(sep) do different things, and there is no string sep that can make s.split(sep) behave like s.split(). That's not unheard of but it does go against our typical expectations. It would have been a better library design if s.split() and s.split(sep)

Re: a splitting headache

2009-10-22 Thread Mensanator
On Oct 22, 8:17 am, David C. Ullrich dullr...@sprynet.com wrote: On Wed, 21 Oct 2009 14:43:48 -0700 (PDT), Mensanator mensana...@aol.com wrote: On Oct 21, 2:46 pm, David C Ullrich dullr...@sprynet.com wrote: On Tue, 20 Oct 2009 15:22:55 -0700, Mensanator wrote: On Oct 20, 1:51 pm,

Re: a splitting headache

2009-10-22 Thread Mensanator
On Oct 22, 10:05 am, John Posner jjpos...@optimum.net wrote: Carl Banks wrote: snip s.split() and s.split(sep) do different things, and there is no string sep that can make s.split(sep) behave like s.split().  That's not unheard of but it does go against our typical expectations.  It

Re: a splitting headache

2009-10-22 Thread rurpy
On 10/22/2009 07:17 AM, David C. Ullrich wrote: On Wed, 21 Oct 2009 14:43:48 -0700 (PDT), Mensanator mensana...@aol.com wrote: On Oct 21, 2:46 pm, David C Ullrich dullr...@sprynet.com wrote: On Tue, 20 Oct 2009 15:22:55 -0700, Mensanator wrote: On Oct 20, 1:51 pm, David C Ullrich

Re: a splitting headache

2009-10-22 Thread John Posner
[resend, with Subject line corrected and formatting crud deleted] Mensanator wrote: That's interesting. If string.splitfields(delim) was equivalent to str.split(sep), it would have been useful to add the phrase str.split(sep) is equivalent to the old string.splitfields(delim) which no longer

Re: a splitting headache

2009-10-22 Thread Mensanator
On Oct 22, 4:35 pm, John Posner jjpos...@optimum.net wrote: [resend, with Subject line corrected and formatting crud deleted] Mensanator wrote: That's interesting. If string.splitfields(delim) was equivalent to str.split(sep), it would have been useful to add the phrase str.split(sep) is

Re: a splitting headache

2009-10-22 Thread Gabriel Genellina
En Thu, 22 Oct 2009 19:45:54 -0300, Mensanator mensana...@aol.com escribió: On Oct 22, 4:35 pm, John Posner jjpos...@optimum.net wrote: Mensanator wrote: That's interesting. If string.splitfields(delim) was equivalent to str.split(sep), it would have been useful to add the phrase

Re: a splitting headache

2009-10-21 Thread David C Ullrich
On Tue, 20 Oct 2009 15:22:55 -0700, Mensanator wrote: On Oct 20, 1:51 pm, David C Ullrich dullr...@sprynet.com wrote: On Thu, 15 Oct 2009 18:18:09 -0700, Mensanator wrote: All I wanted to do is split a binary number into two lists, a list of blocks of consecutive ones and another list of

Re: a splitting headache

2009-10-21 Thread Mensanator
On Oct 21, 2:46 pm, David C Ullrich dullr...@sprynet.com wrote: On Tue, 20 Oct 2009 15:22:55 -0700, Mensanator wrote: On Oct 20, 1:51 pm, David C Ullrich dullr...@sprynet.com wrote: On Thu, 15 Oct 2009 18:18:09 -0700, Mensanator wrote: All I wanted to do is split a binary number into two

Re: a splitting headache

2009-10-21 Thread Carl Banks
On Oct 21, 12:46 pm, David C Ullrich dullr...@sprynet.com wrote: On Tue, 20 Oct 2009 15:22:55 -0700, Mensanator wrote: On Oct 20, 1:51 pm, David C Ullrich dullr...@sprynet.com wrote: I'm not saying either behaviour is wrong, it's just not obvious that the one behaviour doesn't follow from

Re: a splitting headache

2009-10-20 Thread David C Ullrich
On Thu, 15 Oct 2009 18:18:09 -0700, Mensanator wrote: All I wanted to do is split a binary number into two lists, a list of blocks of consecutive ones and another list of blocks of consecutive zeroes. But no, you can't do that. c = '001110' c.split('0') ['', '', '1', '', '', '',

Re: a splitting headache

2009-10-20 Thread Mensanator
On Oct 20, 1:51 pm, David C Ullrich dullr...@sprynet.com wrote: On Thu, 15 Oct 2009 18:18:09 -0700, Mensanator wrote: All I wanted to do is split a binary number into two lists, a list of blocks of consecutive ones and another list of blocks of consecutive zeroes. But no, you can't do

Re: a splitting headache

2009-10-17 Thread Mensanator
On Oct 16, 11:41�pm, Paul Rubin http://phr...@nospam.invalid wrote: Mensanator mensana...@aol.com writes: Thanks, but what I wanted was ['00','1','0','1','0','','00','1','0' '1']. � � c = '00101000101' � � list(''.join(g) for k,g in groupby(c)) � � ['00', '1', '0', '1', '0',

Re: a splitting headache

2009-10-16 Thread Mensanator
On Oct 16, 10:30�am, John Posner jjpos...@optimum.net wrote: Mensenator said: c = '001110' c.split('0') ['', '', '1', '', '', '', '11', ''] Ok, the consecutive delimiters appear as empty strings for reasons unknown (except for the first one). Except when they start or end the

Re: a splitting headache

2009-10-16 Thread Thomas
On Oct 15, 9:18 pm, Mensanator mensana...@aol.com wrote: All I wanted to do is split a binary number into two lists, a list of blocks of consecutive ones and another list of blocks of consecutive zeroes. But no, you can't do that. c = '001110' c.split('0') ['', '', '1', '', '', '',

Re: a splitting headache

2009-10-16 Thread Carl Banks
On Oct 15, 6:57 pm, Ishwor Gurung ishwor.gur...@gmail.com wrote: Too bad groupby is only available in Python2.6+ Since you're here, any chance of getting your NDK team to look into getting some small subset of STL, Boost into Android? Aren't Java collections bad enough? :) Carl Banks --

Re: a splitting headache

2009-10-16 Thread Mensanator
On Oct 16, 8:00�pm, Thomas thom1...@gmail.com wrote: On Oct 15, 9:18�pm, Mensanator mensana...@aol.com wrote: All I wanted to do is split a binary number into two lists, a list of blocks of consecutive ones and another list of blocks of consecutive zeroes. But no, you can't do that.

Re: a splitting headache

2009-10-16 Thread Paul Rubin
Mensanator mensana...@aol.com writes: Thanks, but what I wanted was ['00','1','0','1','0','','00','1','0' '1']. c = '00101000101' list(''.join(g) for k,g in groupby(c)) ['00', '1', '0', '1', '0', '', '00', '1', '0', '1'] is really not that unnatural. --

a splitting headache

2009-10-15 Thread Mensanator
All I wanted to do is split a binary number into two lists, a list of blocks of consecutive ones and another list of blocks of consecutive zeroes. But no, you can't do that. c = '001110' c.split('0') ['', '', '1', '', '', '', '11', ''] Ok, the consecutive delimiters appear as empty

Re: a splitting headache

2009-10-15 Thread Ishwor Gurung
Hi 2009/10/16 Mensanator mensana...@aol.com: All I wanted to do is split a binary number into two lists, a list of blocks of consecutive ones and another list of blocks of consecutive zeroes. Just briefly looked at your problem. Try this:

Re: a splitting headache

2009-10-15 Thread Mel
Mensanator wrote: All I wanted to do is split a binary number into two lists, a list of blocks of consecutive ones and another list of blocks of consecutive zeroes. But no, you can't do that. c = '001110' c.split('0') ['', '', '1', '', '', '', '11', ''] [ ... ] OTOH, if my digits

Re: a splitting headache

2009-10-15 Thread John O'Hagan
On Fri, 16 Oct 2009, Mensanator wrote: All I wanted to do is split a binary number into two lists, a list of blocks of consecutive ones and another list of blocks of consecutive zeroes. [...] That means I can use re to solve my problem after all. c = '001110' re.sub('0','

Re: a splitting headache

2009-10-15 Thread Paul Rubin
Mensanator mensana...@aol.com writes: And the re module doesn't help. f = ' 1 2 3 4' re.split(' ',f) ['', '', '1', '2', '', '3', '', '', '4', '', '', '', ''] filter(bool, re.split(' ', f)) You might also like: from itertools import groupby c = '001110' print

Re: a splitting headache

2009-10-15 Thread Ishwor Gurung
2009/10/16 Paul Rubin http://phr...@nospam.invalid: [...] You might also like:    from itertools import groupby    c = '001110'    print list(list(xs) for k,xs in groupby(c)) Too bad groupby is only available in Python2.6+ Since you're here, any chance of getting your NDK team to look

Re: a splitting headache

2009-10-15 Thread Ishwor Gurung
2009/10/16 Ishwor Gurung ishwor.gur...@gmail.com: 2009/10/16 Paul Rubin http://phr...@nospam.invalid: [...] You might also like:    from itertools import groupby    c = '001110'    print list(list(xs) for k,xs in groupby(c)) Too bad groupby is only available in Python2.6+ OK. I stand

Re: a splitting headache

2009-10-15 Thread Paul Rubin
Ishwor Gurung ishwor.gur...@gmail.com writes: Since you're here, any chance of getting your NDK team to look into getting some small subset of STL, Boost into Android? :-P That'd be awesome thing you know. My what who where? You are confusing me with someone else. --

Re: a splitting headache

2009-10-15 Thread Ishwor Gurung
I think I am getting old :-( Should have Googled already. My what who where?  You are confusing me with someone else. Andy Rubin- http://en.wikipedia.org/wiki/Andy_Rubin Sorry to bother you. -- Regards, Ishwor Gurung -- http://mail.python.org/mailman/listinfo/python-list