[Patches] [ python-Patches-825313 ] Add additional isxxx functions to string object.

SourceForge.net noreply at sourceforge.net
Thu Oct 23 14:11:13 EDT 2003

Patches item #825313, was opened at 2003-10-16 22:47
Message generated for change (Comment added) made by ehuss
You can respond by visiting: 

Category: Core (C code)
Group: Python 2.4
Status: Open
Resolution: None
Priority: 4
Submitted By: Eric Huss (ehuss)
Assigned to: Nobody/Anonymous (nobody)
Summary: Add additional isxxx functions to string object.

Initial Comment:
This patch adds the following ctype.h functions to the 
string object.


These are pretty standard C functions...I'm not sure 
why they were left out.

It also deletes a lot of duplicated code.

This patch might not be 100% useful because it does 
not have the unicode equivalents.  Thoughts?


>Comment By: Eric Huss (ehuss)
Date: 2003-10-23 11:11

Logged In: YES 

isprint is useful to make sure there are "safe" characters in a 
string.  In a tty-based application, and you have potentially 
hostile text to display to the user, you want to make sure 
that no terminal control characters are sent.

isgraph is exactly the same as isprint, except it does not 
include the space character.

I do not understand Brett's comment about isxdigit.  I would 
avoid renaming it since the naming convention already follows 
the C functions.  And it is not the same as isalnum and 
isalpha...which is the same as isdigit (which already exists).  
isxdigit tests for a hexadecimal character (0-9 a-f A-F).

I think it would be mildly useful.  I can follow up with a patch 
for documentation and unit tests.  As for Unicode support, 
unforutnately I do not know where to begin to update 


Comment By: Martin v. Löwis (loewis)
Date: 2003-10-18 02:58

Logged In: YES 

The patch is incomplete, as it comes without documentation
and test cases. Eric, I would normally request these at this
point, but I'm also with Brett that wrapping these functions
might be useless.

What is the rationale for including them?


Comment By: Brett Cannon (bcannon)
Date: 2003-10-17 12:53

Logged In: YES 

I don't really see a good use for any of these.  Chances that most 
people are going to need most of these is very minor (heck, I 
don't even know what isgraph would test for).

isxdigit might be slightly helpful if you renamed it isnum, but you 
can fake that already with ``x.isalnum() and not x.isalpha()``.

But in general I am -1 on these.  str has enough methods as it is.


Comment By: Andrew Gaul (gaul)
Date: 2003-10-17 12:26

Logged In: YES 

I like shedding ~80 lines with is_helper, especially if you
add inline.  Otherwise, function call overhead might be
incurred for every call to C isfoo() instead of inlining the
comparison.  I dislike increasing the distinction between
ASCII and Unicode strings, although Unicode strings already
have isdecimal and isnumeric methods which ASCII strings
lack.  I would at least add iscntrl, ispunct, and isxdigit
to Unicode strings if they are added to ASCII strings.


You can respond by visiting: 

More information about the Patches mailing list