Issue825313
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2003-10-17 05:47 by ehuss, last changed 2022-04-10 16:11 by admin. This issue is now closed.
Files | ||||
---|---|---|---|---|
File name | Uploaded | Description | Edit | |
stringobject.c.patch | ehuss, 2003-10-17 05:47 | Add missing isxxx functions to stringobject.c. |
Messages (8) | |||
---|---|---|---|
msg44782 - (view) | Author: Eric Huss (ehuss) | Date: 2003-10-17 05:47 | |
This patch adds the following ctype.h functions to the string object. iscntrl isgraph isprint ispunct isxdigit 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? |
|||
msg44783 - (view) | Author: Andrew Gaul (gaul) | Date: 2003-10-17 19:26 | |
Logged In: YES user_id=139865 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. |
|||
msg44784 - (view) | Author: Brett Cannon (brett.cannon) * | Date: 2003-10-17 19:53 | |
Logged In: YES user_id=357491 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. |
|||
msg44785 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2003-10-18 09:58 | |
Logged In: YES user_id=21627 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? |
|||
msg44786 - (view) | Author: Eric Huss (ehuss) | Date: 2003-10-23 18:11 | |
Logged In: YES user_id=393416 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 makeunicodedata.py. |
|||
msg44787 - (view) | Author: Brett Cannon (brett.cannon) * | Date: 2003-10-24 00:34 | |
Logged In: YES user_id=357491 You don't need to understand my comment because I goofed. For some reason I remember reading ``help(str.isdigit)`` and it saying it only worked for a single character. I still don't find these that useful. isgraph seems especially useless since you could easily just strip the whitespace out and then call isprint on it. For the argument of keeping the names with C, that is not valid. This is being introduced into Python for the first time and thus should have a proper name. There is not enough of a widespread connection to C in terms of these functions to have to worry about keeping the name the same. Regardless of all of this I am still -1 on all of the methods. |
|||
msg44788 - (view) | Author: Marc-Andre Lemburg (lemburg) * | Date: 2003-10-24 07:34 | |
Logged In: YES user_id=38388 -1 from here. You can have the same using a regular expression character group built using the unicodedata(base) or just using a static mapping for 8-bit chars. There are too few use cases for these methods that it would make sense adding extra logic and static data to make the mapping fast enough. Brett, feel free to close this request. |
|||
msg44789 - (view) | Author: Brett Cannon (brett.cannon) * | Date: 2003-10-24 20:49 | |
Logged In: YES user_id=357491 OK, having MA, Martin, and me say "no" works for me. This patch is rejected. Sorry, Eric. What you might want to do, though, Eric, is see if you could help out with the proposed textutil module that has recently been proposed on python-dev. Basically the only thing that would go into this mystical module is a new string substitution function, but this might have a place there. That thread is entitled "Can we please have a better dict interpolation syntax?" from this month (October 2003). |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:11:46 | admin | set | github: 39422 |
2003-10-17 05:47:23 | ehuss | create |