If the string module is deprecated...

Alex Martelli aleaxit at yahoo.com
Mon Aug 30 03:05:13 EDT 2004


Paul McGuire <ptmcg at austin.rr._bogus_.com> wrote:

> ... what will become of the module-level constants, such as uppercase,
> digits, hexdigits, etc.?  Will they become class-level constants of the str
> class?

That would seem the most natural solution, yes.  Taking advantage of
that change, it might be good to have in classes str (and unicode) only
real constants, independent of locale, and move locale-dependent stuff
to module locale.  Other related issues were debated in the relatively
recent past on python-dev -- e.g., if we have str.digits, how do we
discourage beginners from (most likely incorrectly) testing 'if c in
str.digits' where they should be coding 'if c.isdigit()' instead?  Or do
we?  Or should we perhaps make str.digits (&c) instances of a funky
black-magic subclass of str with a __contains__ method whose semantics
are quite different from str's own implementation of that method?  It is
definitely true that beginners just love coding tests such as 'if c in
str.digits' &c... they're doing so in droves today with string.digits...
I don't recall a consensus being reached, which may be why nothing much
has happened yet on this score.


Alex



More information about the Python-list mailing list