Re: stringobject question
On Tue, Jun 13, 2000 at 10:53:58PM -0500, Al-Amerrho H. Amerin wrote:
Is this a bug or a feature?:
Python 1.6a2 (#4, Jun 9 2000, 02:22:41) [GCC 2.95.2 19991024 (release)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Copyright 1995-2000 Corporation for National Research Initiatives (CNRI)
''.isdigit() 1 ''.isspace() 1
Good point, maybe. The __docs__ say: "S.isdigit() -> int\n\ \n\ Return 1 if there are only digit characters in S,\n\ 0 otherwise."; static char isspace__doc__[] = "S.isspace() -> int\n\ \n\ Return 1 if there are only whitespace characters in S,\n\ 0 otherwise."; I am not an English language lawyer so I could see both interpretations from the doc strings. I agree, that the result with a zero length string is surprising. Hi All, Which should it be? Sorry, if this has been covered. Trent -- Trent Mick trentm@activestate.com
Trent Mick wrote:
On Tue, Jun 13, 2000 at 10:53:58PM -0500, Al-Amerrho H. Amerin wrote:
Is this a bug or a feature?:
Python 1.6a2 (#4, Jun 9 2000, 02:22:41) [GCC 2.95.2 19991024 (release)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Copyright 1995-2000 Corporation for National Research Initiatives (CNRI)
''.isdigit() 1 ''.isspace() 1
Good point, maybe. The __docs__ say:
"S.isdigit() -> int\n\ \n\ Return 1 if there are only digit characters in S,\n\ 0 otherwise.";
static char isspace__doc__[] = "S.isspace() -> int\n\ \n\ Return 1 if there are only whitespace characters in S,\n\ 0 otherwise.";
I am not an English language lawyer so I could see both interpretations from the doc strings. I agree, that the result with a zero length string is surprising.
Hi All, Which should it be? Sorry, if this has been covered.
I guess it's a bug... a subtle one though, because in a certain sense both 1 and 0 are acceptable. But since '' is considered to be false, I think that returning 0 makes more sense. I'll fix this to return 0 for emtpy strings and Unicode objects. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/
On Wed, 14 Jun 2000, M.-A. Lemburg wrote:
''.isdigit() 1 ''.isspace() 1
Good point, maybe. The __docs__ say:
"S.isdigit() -> int\n\ \n\ Return 1 if there are only digit characters in S,\n\ 0 otherwise.";
static char isspace__doc__[] = "S.isspace() -> int\n\ \n\ Return 1 if there are only whitespace characters in S,\n\ 0 otherwise.";
I am not an English language lawyer so I could see both interpretations from the doc strings. I agree, that the result with a zero length string is surprising.
Hi All, Which should it be? Sorry, if this has been covered.
I guess it's a bug... a subtle one though, because in a certain sense both 1 and 0 are acceptable. But since '' is considered to be false, I think that returning 0 makes more sense.
I'll fix this to return 0 for emtpy strings and Unicode objects.
I just realized something: if you change the semantics to mean "number of digits", you'll get the right answer for all 0- and 1- length strings and unicode objects. just-an-observation-ly y'rs, Z. -- Moshe Zadka <moshez@math.huji.ac.il> http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com
Moshe Zadka wrote:
On Wed, 14 Jun 2000, M.-A. Lemburg wrote:
> ''.isdigit() 1 > ''.isspace() 1
Good point, maybe. The __docs__ say:
"S.isdigit() -> int\n\ \n\ Return 1 if there are only digit characters in S,\n\ 0 otherwise.";
static char isspace__doc__[] = "S.isspace() -> int\n\ \n\ Return 1 if there are only whitespace characters in S,\n\ 0 otherwise.";
I am not an English language lawyer so I could see both interpretations from the doc strings. I agree, that the result with a zero length string is surprising.
Hi All, Which should it be? Sorry, if this has been covered.
I guess it's a bug... a subtle one though, because in a certain sense both 1 and 0 are acceptable. But since '' is considered to be false, I think that returning 0 makes more sense.
I'll fix this to return 0 for emtpy strings and Unicode objects.
I just realized something: if you change the semantics to mean "number of digits", you'll get the right answer for all 0- and 1- length strings and unicode objects.
Hmm, the .isXXX() tests should return 1/0 since they test properties rather than count characters. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/
On Wed, Jun 14, 2000 at 10:43:45AM +0200, M . -A . Lemburg wrote:
I guess it's a bug... a subtle one though, because in a certain sense both 1 and 0 are acceptable. But since '' is considered to be false, I think that returning 0 makes more sense.
I'll fix this to return 0 for emtpy strings and Unicode objects.
These are copied from Java, are they not? What do the Java equivalents return? Trent -- Trent Mick trentm@activestate.com
On Wed, Jun 14, 2000 at 10:43:45AM +0200, M . -A . Lemburg wrote:
I guess it's a bug... a subtle one though, because in a certain sense both 1 and 0 are acceptable. But since '' is considered to be false, I think that returning 0 makes more sense.
I'll fix this to return 0 for emtpy strings and Unicode objects.
[Trent Mick]
These are copied from Java, are they not? What do the Java equivalents return?
The .isXX methods does not exists on java strings, only on the Character class. So in java they can never be called on anything with length 0. regards, finn
On Thu, Jun 15, 2000 at 06:16:03PM +0000, Finn Bock wrote:
These are copied from Java, are they not? What do the Java equivalents return?
The .isXX methods does not exists on java strings, only on the Character class. So in java they can never be called on anything with length 0.
Okeedoke, so go with the changes that MAL made s.t. ''.isdigit() returns 0, unless others have any opposition. Trent -- Trent Mick trentm@activestate.com
Trent Mick writes:
Okeedoke, so go with the changes that MAL made s.t. ''.isdigit() returns 0, unless others have any opposition.
This sounds good to me. Marc-Andre, go ahead and checkin anything that isn't already in whenever you're ready; I've not seen any hints of opposition yet, and there's been enough waiting to just check it in. -Fred -- Fred L. Drake, Jr. <fdrake at beopen.com> BeOpen PythonLabs Team Member
On Thu, Jun 15, 2000 at 02:34:02PM -0400, Fred L. Drake, Jr. wrote:
Trent Mick writes:
Okeedoke, so go with the changes that MAL made s.t. ''.isdigit() returns 0, unless others have any opposition.
This sounds good to me. Marc-Andre, go ahead and checkin anything that isn't already in whenever you're ready; I've not seen any hints of opposition yet, and there's been enough waiting to just check it in.
Trent Mick wrote:
On Thu, Jun 15, 2000 at 02:34:02PM -0400, Fred L. Drake, Jr. wrote:
Trent Mick writes:
Okeedoke, so go with the changes that MAL made s.t. ''.isdigit() returns 0, unless others have any opposition.
This sounds good to me. Marc-Andre, go ahead and checkin anything that isn't already in whenever you're ready; I've not seen any hints of opposition yet, and there's been enough waiting to just check it in.
From what I have seen it is already in.
Right ;-) -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/
M.-A. Lemburg writes:
Trent Mick wrote:
From what I have seen it is already in.
Right ;-)
I may have mentioned that I've been losing track of all the patches. ;) -Fred -- Fred L. Drake, Jr. <fdrake at beopen.com> BeOpen PythonLabs Team Member
participants (5)
-
bckfnn@worldonline.dk
-
Fred L. Drake, Jr.
-
M.-A. Lemburg
-
Moshe Zadka
-
Trent Mick