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.

classification
Title: Class attributes for string object
Type: Stage:
Components: Interpreter Core Versions: Python 2.3
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, nnorwitz, rhettinger, theller
Priority: normal Keywords: patch

Created on 2002-05-29 07:24 by theller, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
stringobject.diff theller, 2002-05-29 07:24 Patch for stringobject.c
Messages (4)
msg40164 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2002-05-29 07:24
This patch attaches the following class attributes to 
stringobject:
whitespace, lowercase, ascii_lowercase, uppercase, 
ascii_uppercase, letters, ascii_letters, digits, hexdigits, 
octdigits, punctuation, printable.

The implementation is nearly trivial, OTOH I didn't find a 
place where PyString_Type is initialized, so I did it lazily 
in the tp_getattro function.
msg40165 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2002-05-29 16:51
Logged In: YES 
user_id=80475

I understand that these are being put in to provide 
alternatives to the string module but  had always thought 
they should have been mappings rather that strings.  Is 
now a good time to make the switch before this all gets 
set in stone?

if c not in str.printable: c='*'  # works faster as a mapping
msg40166 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-05-30 12:40
Logged In: YES 
user_id=33168

Based on the recent discussion on python-dev, it seems better 
to dynamically init lowercase, uppercase, letters, and
whitespace;
so the locale is used.  Probably punctuation and printable
should be done this way too, but I'm not sure.

Here's the end of the discussion:
http://mail.python.org/pipermail/python-dev/2002-May/024655.html
Some other notes:

 * class_attrs should be static (before struct).
 * you could make #defines for the letters (like "ABC" ...) and 
    re-use them to init the class_attrs to avoid some
duplication
    (this is not important, but could be easier).
 * The getattro seems hacky, but I don't know if there is a
better way.
 * The // comment would need to be removed.
msg40167 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-05-30 14:00
Logged In: YES 
user_id=6380

I believe that we shouldn't expose these sets as variables
at all; we should expose them through methods like
islower(). Therefore I'm rejecting this patch.
History
Date User Action Args
2022-04-10 16:05:21adminsetgithub: 36660
2002-05-29 07:24:25thellercreate