Re: Newbie question regarding string.split()

2007-04-21 Thread Karthik Gurusamy
On Apr 20, 11:51 am, kevinliu23 <[EMAIL PROTECTED]> wrote: > Hey guys, > > So I have a question regarding the split() function in the string > module. Let's say I have an string... > > input = "2b 3 4bx 5b 2c 4a 5a 6" > projectOptions = (input.replace(" ", "")).split('2') > print projectOptions > >

Re: Newbie question regarding string.split()

2007-04-21 Thread kevinliu23
On Apr 21, 3:30 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > kevinliu23 a écrit :> Hey guys, > > > So I have a question regarding the split() function in the string > > module. Let's say I have an string... > > > input = "2b 3 4bx 5b 2c 4a 5a 6" > > projectOptions = (input.replace(" ", ""))

Re: Newbie question regarding string.split()

2007-04-21 Thread Bruno Desthuilliers
kevinliu23 a écrit : > Hey guys, > > So I have a question regarding the split() function in the string > module. Let's say I have an string... > > input = "2b 3 4bx 5b 2c 4a 5a 6" > projectOptions = (input.replace(" ", "")).split('2') The parens around the call to input.replace are useless: pr

Re: Newbie question regarding string.split()

2007-04-20 Thread Steven D'Aprano
On Fri, 20 Apr 2007 12:15:33 -0700, kyosohma wrote: > One hack to make it work is to add the following line right before you > print "projectOptions": > > projectOptions.pop(0) # pop the first element out of the list Which will introduce a nice bug into the Original Poster's code when the input

Re: Newbie question regarding string.split()

2007-04-20 Thread Steve Holden
Tommy Grav wrote: > On Apr 20, 2007, at 3:15 PM, [EMAIL PROTECTED] wrote: >> On Apr 20, 1:51 pm, kevinliu23 <[EMAIL PROTECTED]> wrote: >>> ['', 'b34bx5b', 'c4a5a6'] >>> >>> My question is, why is the first element of projectOptions an empty >>> string? What can I do so that the first element is not

Re: Newbie question regarding string.split()

2007-04-20 Thread Tommy Grav
On Apr 20, 2007, at 3:15 PM, [EMAIL PROTECTED] wrote: > On Apr 20, 1:51 pm, kevinliu23 <[EMAIL PROTECTED]> wrote: >> ['', 'b34bx5b', 'c4a5a6'] >> >> My question is, why is the first element of projectOptions an empty >> string? What can I do so that the first element is not an empty >> string? but

Re: Newbie question regarding string.split()

2007-04-20 Thread Stephen Lewitowski
kevinliu23 wrote: > Hey guys, > > So I have a question regarding the split() function in the string > module. Let's say I have an string... > > input = "2b 3 4bx 5b 2c 4a 5a 6" > projectOptions = (input.replace(" ", "")).split('2') > print projectOptions > > ['', 'b34bx5b', 'c4a5a6'] > > My que

Re: Newbie question regarding string.split()

2007-04-20 Thread kyosohma
On Apr 20, 1:51 pm, kevinliu23 <[EMAIL PROTECTED]> wrote: > Hey guys, > > So I have a question regarding the split() function in the string > module. Let's say I have an string... > > input = "2b 3 4bx 5b 2c 4a 5a 6" > projectOptions = (input.replace(" ", "")).split('2') > print projectOptions > >

Re: Newbie question regarding string.split()

2007-04-20 Thread Steve Holden
kevinliu23 wrote: > Hey guys, > > So I have a question regarding the split() function in the string > module. Let's say I have an string... > First of all, the string module is pretty much deprecated nowadays. What you are actually using, the .split() method of a string, is the preferred way to

Re: Newbie question regarding string.split()

2007-04-20 Thread Grant Edwards
On 2007-04-20, kevinliu23 <[EMAIL PROTECTED]> wrote: > Hey guys, > > So I have a question regarding the split() function in the string > module. Let's say I have an string... > > input = "2b 3 4bx 5b 2c 4a 5a 6" > projectOptions = (input.replace(" ", "")).split('2') > print projectOptions > > ['',

Newbie question regarding string.split()

2007-04-20 Thread kevinliu23
Hey guys, So I have a question regarding the split() function in the string module. Let's say I have an string... input = "2b 3 4bx 5b 2c 4a 5a 6" projectOptions = (input.replace(" ", "")).split('2') print projectOptions ['', 'b34bx5b', 'c4a5a6'] My question is, why is the first element of proj