Re: a splitting headache

2009-10-26 Thread Mensanator
On Oct 26, 7:28 am, Vlastimil Brom wrote: > 2009/10/26 jhermann : > > > > > > > On 16 Okt., 02:18, 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. > > > Back to the

Re: a splitting headache

2009-10-26 Thread Vlastimil Brom
2009/10/26 jhermann : > On 16 Okt., 02:18, 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. > > Back to the OP's problem, the obvious (if you know the std lib) and > easy so

Re: a splitting headache

2009-10-26 Thread jhermann
On 16 Okt., 02:18, 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. Back to the OP's problem, the obvious (if you know the std lib) and easy solution is: >>> c = '0010100

Re: a splitting headache

2009-10-23 Thread Mensanator
On Oct 22, 2:23 pm, Falcolas wrote: > On Oct 22, 11:56 am, Mensanator 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/ -- http://mail.python.org/mailman/listinfo/pyth

Re: a splitting headache

2009-10-23 Thread Mensanator
On Oct 22, 1:22 pm, Paul Rudin wrote: > Mensanator 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 Paul Rudin
Mensanator 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-22 Thread Gabriel Genellina
En Thu, 22 Oct 2009 19:45:54 -0300, Mensanator escribió: On Oct 22, 4:35 pm, John Posner 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 > "str.split(sep) is equivalent to the old strin

Re: a splitting headache

2009-10-22 Thread Mensanator
On Oct 22, 4:35 pm, John Posner 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 equivalent

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 ex

Re: a splitting headache

2009-10-22 Thread rurpy
On 10/22/2009 06:32 AM, David C. Ullrich wrote: > On Wed, 21 Oct 2009 22:47:24 -0700 (PDT), Carl Banks > wrote: > >>On Oct 21, 12:46 pm, David C Ullrich wrote: >>> On Tue, 20 Oct 2009 15:22:55 -0700, Mensanator wrote: >>> > On Oct 20, 1:51 pm, David C Ullrich wrote: >>> > I'm not saying either b

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 > wrote: > >>On Oct 21, 2:46 pm, David C Ullrich wrote: >>> On Tue, 20 Oct 2009 15:22:55 -0700, Mensanator wrote: >>> > On Oct 20, 1:51 pm, David C Ullrich wrote: >>> >> On Thu, 15 Oct 2009 18:

Re: a splitting headache

2009-10-22 Thread Mensanator
On Oct 22, 10:05 am, John Posner wrote: > Carl Banks wrote: > > > > > 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 bee

Re: a splitting headache

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

Re: a splitting headache

2009-10-22 Thread John Posner
Carl Banks wrote: 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) were d

Re: a splitting headache

2009-10-22 Thread David C . Ullrich
On Wed, 21 Oct 2009 14:43:48 -0700 (PDT), Mensanator wrote: >On Oct 21, 2:46 pm, David C Ullrich wrote: >> On Tue, 20 Oct 2009 15:22:55 -0700, Mensanator wrote: >> > On Oct 20, 1:51 pm, David C Ullrich wrote: >> >> On Thu, 15 Oct 2009 18:18:09 -0700, Mensanator wrote: >> >> > All I wanted to do

Re: a splitting headache

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

Re: a splitting headache

2009-10-22 Thread David C . Ullrich
On Wed, 21 Oct 2009 14:43:48 -0700 (PDT), Mensanator wrote: >On Oct 21, 2:46 pm, David C Ullrich wrote: >> On Tue, 20 Oct 2009 15:22:55 -0700, Mensanator wrote: >> > On Oct 20, 1:51 pm, David C Ullrich wrote: >> >> On Thu, 15 Oct 2009 18:18:09 -0700, Mensanator wrote: >> >> > All I wanted to do

Re: a splitting headache

2009-10-22 Thread David C . Ullrich
On Wed, 21 Oct 2009 22:47:24 -0700 (PDT), Carl Banks wrote: >On Oct 21, 12:46 pm, David C Ullrich wrote: >> On Tue, 20 Oct 2009 15:22:55 -0700, Mensanator wrote: >> > On Oct 20, 1:51 pm, David C Ullrich wrote: >> > I'm not saying either behaviour is wrong, it's just not obvious that the >> > on

Re: a splitting headache

2009-10-21 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 wrote: > >> On Tue, 20 Oct 2009 15:22:55 -0700, Mensanator wrote: > >> > On Oct 20, 1:51 pm, David C Ullrich wrote: > >> > I'm not saying either behaviour is w

Re: a splitting headache

2009-10-21 Thread Mensanator
On Oct 21, 11:21�pm, John Yeung wrote: > On Oct 21, 5:43�pm, Mensanator wrote: > > > >>> '01110'.split('0') > > > ['', '1', '', '', '', '11', ''] > > > is a perfect example. It shows the empty strings > > generated from the leading and trailing delimiters, > > and also that you get 3 empty st

Re: a splitting headache

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

Re: a splitting headache

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

Re: a splitting headache

2009-10-21 Thread John Yeung
On Oct 21, 5:43 pm, Mensanator wrote: > >>> '01110'.split('0') > > ['', '1', '', '', '', '11', ''] > > is a perfect example. It shows the empty strings > generated from the leading and trailing delimiters, > and also that you get 3 empty strings between the > '1's, not 4. When creating docume

Re: a splitting headache

2009-10-21 Thread Mensanator
On Oct 21, 2:46 pm, David C Ullrich wrote: > On Tue, 20 Oct 2009 15:22:55 -0700, Mensanator wrote: > > On Oct 20, 1:51 pm, David C Ullrich 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 o

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 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 cons

Re: a splitting headache

2009-10-20 Thread Mensanator
On Oct 20, 1:51 pm, David C Ullrich 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 that. > > >>>

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-17 Thread Mensanator
On Oct 16, 11:41�pm, Paul Rubin wrote: > Mensanator 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 Paul Rubin
Mensanator 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. -- http://mail.python.org/m

Re: a splitting headache

2009-10-16 Thread Mensanator
On Oct 16, 8:00�pm, Thomas wrote: > On Oct 15, 9:18�pm, 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 = '001000

Re: a splitting headache

2009-10-16 Thread Carl Banks
On Oct 15, 6:57 pm, Ishwor Gurung 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 -- http://mail.python.org

Re: a splitting headache

2009-10-16 Thread Thomas
On Oct 15, 9:18 pm, 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', '', '', '', '1

Re: a splitting headache

2009-10-16 Thread Mensanator
On Oct 16, 10:30�am, John Posner 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 John Posner
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 string in which case the first one is included. Maybe there's a r

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

Re: a splitting headache

2009-10-15 Thread Paul Rubin
Ishwor Gurung 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. -- http://mail.python.org/mailman/listinfo/pytho

Re: a splitting headache

2009-10-15 Thread Ishwor Gurung
2009/10/16 Ishwor Gurung : > 2009/10/16 Paul Rubin : > [...] >> 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 corrected

Re: a splitting headache

2009-10-15 Thread Ishwor Gurung
2009/10/16 Paul Rubin : [...] > 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 lo

Re: a splitting headache

2009-10-15 Thread Paul Rubin
Mensanator 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 list(list(xs

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 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

Re: a splitting headache

2009-10-15 Thread Ishwor Gurung
Hi 2009/10/16 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. Just briefly looked at your problem. Try this: http://www.builderau.com.au/program/python/soa/Run-length-encoding-in-P