If the string module is deprecated...

P

Paul McGuire

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

-- Paul
 
J

John J. Lee

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

I don't see why not.

One design decision I don't understand, though (which doesn't crop up
in the particular cases you list above):

staticmethods can be invoked through a class instance:
.... @staticmethod
.... def bar():
.... print 'bar'
....
This is the issue that turned list.sorted() into builtin sorted() in
2.4 -- people would get confused expecting that [3,2,1].sorted() to
return [1,2,3], rather than raise TypeError.

Seems there is some disagreement amongst language desingers on whether
polymorphism is a good thing in static methods.


John
 
A

Alex Martelli

Paul McGuire said:
... 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,204
Messages
2,571,065
Members
47,672
Latest member
svaraho

Latest Threads

Top