Re: s.split() on multiple separators

2007-10-04 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Antoon Pardon wrote: > On 2007-10-01, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > >> En Sun, 30 Sep 2007 16:16:30 -0300, <[EMAIL PROTECTED]> escribi?: >> From my POV, if I want sequence from here to there, it should include >>> both here and there. >>> >>> I

Re: s.split() on multiple separators

2007-10-02 Thread [david]
Gabriel Genellina wrote: > En Sun, 30 Sep 2007 16:16:30 -0300, <[EMAIL PROTECTED]> escribi�: > >>> From my POV, if I want sequence from here to there, it should include >> both here and there. >> >> I do understand the consequences of making high bound exclusive, which >> is more elegant code: xra

Re: s.split() on multiple separators

2007-10-02 Thread Antoon Pardon
On 2007-10-02, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > Antoon Pardon <[EMAIL PROTECTED]> writes: > >> It may be convincing if you only consider natural numbers in >> ascending order. Suppose you have the sequence a .. b and you want >> the reverse. If you work with included bounds the reverse i

Re: s.split() on multiple separators

2007-10-02 Thread Hrvoje Niksic
Antoon Pardon <[EMAIL PROTECTED]> writes: > It may be convincing if you only consider natural numbers in > ascending order. Suppose you have the sequence a .. b and you want > the reverse. If you work with included bounds the reverse is just b > .. a. If you use the python convention, things beco

Re: s.split() on multiple separators

2007-10-02 Thread Antoon Pardon
On 2007-10-01, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > En Sun, 30 Sep 2007 16:16:30 -0300, <[EMAIL PROTECTED]> escribi?: > >>> From my POV, if I want sequence from here to there, it should include >> both here and there. >> >> I do understand the consequences of making high bound exclusive,

Re: s.split() on multiple separators

2007-09-30 Thread Gabriel Genellina
En Sun, 30 Sep 2007 16:16:30 -0300, <[EMAIL PROTECTED]> escribi�: >> From my POV, if I want sequence from here to there, it should include > both here and there. > > I do understand the consequences of making high bound exclusive, which > is more elegant code: xrange(len(c)). But it does seem a bi

Re: s.split() on multiple separators

2007-09-30 Thread Paul Hankin
On Sep 30, 8:16 pm, [EMAIL PROTECTED] wrote: > > > c=' abcde abc cba fdsa bcd '.split() > > > dels='ce ' > > > for j in dels: > > >cp=[] > > >for i in xrange(0,len(c)-1): > > > The "-1" looks like a bug; remember in Python 'stop' bounds > > are exclusive. The indexes of c are simply xran

Re: s.split() on multiple separators

2007-09-30 Thread mrkafk
> > c=' abcde abc cba fdsa bcd '.split() > > dels='ce ' > > for j in dels: > >cp=[] > >for i in xrange(0,len(c)-1): > > The "-1" looks like a bug; remember in Python 'stop' bounds > are exclusive. The indexes of c are simply xrange(len(c)). Yep. Just found it out, though this seems a bi

Re: s.split() on multiple separators

2007-09-30 Thread mrkafk
On 30 Wrz, 20:27, William James <[EMAIL PROTECTED]> wrote: > On Sep 30, 8:53 am, [EMAIL PROTECTED] wrote: > E:\Ruby>irb > irb(main):001:0> ' abcde abc cba fdsa bcd '.split(/[ce ]/) > => ["", "ab", "d", "", "ab", "", "", "ba", "fdsa", "b", "d"] That's acceptable only if you write perfect ruby-to-p

Re: s.split() on multiple separators

2007-09-30 Thread mrkafk
> > ['ab', 'd', '', 'ab', '', ''] > > Given your original string, I'm not sure how that would be the > expected result of "split c on the characters in dels". Oops, the inner loop should be: for i in xrange(0,len(c)): Now it works. > >>> c=' abcde abc cba fdsa bcd ' > >>> import re > >>

Re: s.split() on multiple separators

2007-09-30 Thread William James
On Sep 30, 8:53 am, [EMAIL PROTECTED] wrote: > Hello everyone, > > OK, so I want to split a string c into words using several different > separators from a list (dels). > > I can do this the following C-like way: > > >>> c=' abcde abc cba fdsa bcd '.split() > >>> dels='ce ' > >>> for j in dels: > >

Re: s.split() on multiple separators

2007-09-30 Thread Bryan Olson
[EMAIL PROTECTED] wrote: > Hello everyone, > > OK, so I want to split a string c into words using several different > separators from a list (dels). > > I can do this the following C-like way: > > c=' abcde abc cba fdsa bcd '.split() > dels='ce ' > for j in dels: > cp=[] > for i i

Re: s.split() on multiple separators

2007-09-30 Thread Tim Chase
> OK, so I want to split a string c into words using several different > separators from a list (dels). > > I can do this the following C-like way: > c=' abcde abc cba fdsa bcd '.split() dels='ce ' for j in dels: > cp=[] > for i in xrange(0,len(c)-1): > cp

Re: s.split() on multiple separators

2007-09-30 Thread Francesco Guerrieri
On 9/30/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hello everyone, > > OK, so I want to split a string c into words using several different > separators from a list (dels). Have a look at this recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303342 which contains several w

Re: s.split() on multiple separators

2007-09-30 Thread Francesco Guerrieri
On 9/30/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hello everyone, > > OK, so I want to split a string c into words using several different > separators from a list (dels). Have a look at this recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303342 which contains several w

s.split() on multiple separators

2007-09-30 Thread mrkafk
Hello everyone, OK, so I want to split a string c into words using several different separators from a list (dels). I can do this the following C-like way: >>> c=' abcde abc cba fdsa bcd '.split() >>> dels='ce ' >>> for j in dels: cp=[] for i in xrange(0,len(c)-1):