[Patches] [ python-Patches-561832 ] Class attributes for string object
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 30 May 2002 07:00:23 -0700
Patches item #561832, was opened at 2002-05-29 03:24
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=561832&group_id=5470
Category: Core (C code)
Group: Python 2.3
>Status: Closed
>Resolution: Rejected
Priority: 5
Submitted By: Thomas Heller (theller)
Assigned to: Nobody/Anonymous (nobody)
Summary: Class attributes for string object
Initial Comment:
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.
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-05-30 10:00
Message:
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.
----------------------------------------------------------------------
Comment By: Neal Norwitz (nnorwitz)
Date: 2002-05-30 08:40
Message:
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.
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2002-05-29 12:51
Message:
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
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=561832&group_id=5470