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.split
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 containing one empty
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
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']
a b.split
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', 't',
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('') to return
[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
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 expected the second
[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, you
would have