Re: Behaviour of str.split

2005-04-20 Thread David Fraser
Bengt Richter wrote: On Wed, 20 Apr 2005 10:55:18 +0200, David Fraser <[EMAIL PROTECTED]> wrote: Greg Ewing wrote: Will McGugan wrote: Hi, I'm curious about the behaviour of the str.split() when applied to empty strings. "".split() returns an empty list, however.. "".split("*") returns a list c

Re: Behaviour of str.split

2005-04-20 Thread Bengt Richter
On Wed, 20 Apr 2005 10:55:18 +0200, David Fraser <[EMAIL PROTECTED]> wrote: >Greg Ewing wrote: >> Will McGugan wrote: >> >>> Hi, >>> >>> I'm curious about the behaviour of the str.split() when applied to >>> empty strings. >>> >>> "".split() returns an empty list, however.. >>> >>> "".split("*")

Re: Behaviour of str.split

2005-04-20 Thread David Fraser
Greg Ewing wrote: Will McGugan wrote: Hi, I'm curious about the behaviour of the str.split() when applied to empty strings. "".split() returns an empty list, however.. "".split("*") returns a list containing one empty string. Both of these make sense as limiting cases. Consider >>> "a b c".spli

Re: Behaviour of str.split

2005-04-19 Thread Greg Ewing
Will McGugan wrote: Hi, I'm curious about the behaviour of the str.split() when applied to empty strings. "".split() returns an empty list, however.. "".split("*") returns a list containing one empty string. Both of these make sense as limiting cases. Consider >>> "a b c".split() ['a', 'b', 'c']

Re: Behaviour of str.split

2005-04-18 Thread Raymond Hettinger
[Will McGugan] > >I'm curious about the behaviour of the str.split() when applied to empty > >strings. > > > >"".split() returns an empty list, however.. > > > >"".split("*") returns a list containing one empty string. [John Machin] > You are missing a perusal of the documentation. Had you done so

Re: Behaviour of str.split

2005-04-18 Thread John Machin
On Mon, 18 Apr 2005 16:16:00 +0100, Will McGugan <[EMAIL PROTECTED]> wrote: >Hi, > >I'm curious about the behaviour of the str.split() when applied to empty >strings. > >"".split() returns an empty list, however.. > >"".split("*") returns a list containing one empty string. > >I would have expect

Re: Behaviour of str.split

2005-04-18 Thread runes
[Tim N. van der Leeuw] > Fortunately, this is easy to write as: list("mystring"). Sure, and map(None, "mystring") Anyways, I have settled with this bevaviour, more or less ;-) Rune -- http://mail.python.org/mailman/listinfo/python-list

Re: Behaviour of str.split

2005-04-18 Thread Tim N. van der Leeuw
runes wrote: > The behaviour of "".split("*") is not that strange as the splitpoint > always disappear. The re.split() have a nice option to keep the > splitpoint which the str.split should have, I think. > > One expectation I keep fighting within myself is that I expect > > "mystring".split('') t

Re: Behaviour of str.split

2005-04-18 Thread runes
The behaviour of "".split("*") is not that strange as the splitpoint always disappear. The re.split() have a nice option to keep the splitpoint which the str.split should have, I think. One expectation I keep fighting within myself is that I expect "mystring".split('') to return ['m', 'y', 's',

Behaviour of str.split

2005-04-18 Thread Will McGugan
Hi, I'm curious about the behaviour of the str.split() when applied to empty strings. "".split() returns an empty list, however.. "".split("*") returns a list containing one empty string. I would have expected the second example to have also returned an empty list. What am I missing? TIA, Will