[Python-Dev] Re: other "magic strings" issues

Marangozov, Vladimir (Vladimir) vladimir.marangozov at optimay.com
Mon Nov 10 16:12:35 EST 2003


> I do think that keeping the string module around without all the
> functions it historically contained would be a mistake, confusing
> folks.  This error is pretty clear:
>   >>> import string
>   Traceback (most recent call last):
>     File "<stdin>", line 1, in ?
>   ImportError: No module named string
>   >>> 
> But this one is much more mystifying:
>   >>> import string
>   >>> print string.join(["a", "b"], ".")
>   Traceback (most recent call last):
>     File "<stdin>", line 1, in ?
>   AttributeError: 'module' object has no attribute 'join'
>  >>> 

I am trying to understand what's the bottom line of this thread.
It looks like people are suggesting that the venerable string
module should vanish + provide its functions as object attributes.

Well, I have to say that I actually like the fact that I can be
procedural with strings and not object-oriented.  Having all str
functions as object attributes is too much OO for my mind with
regard to this basic type.  And too much OOrientation isn't
always simple to grasp (despite that we can have anything as an
object attribute now and regardless some nice pipe-like serialized
string constructs achieved with attributes).

Put it another way, it's good to have all string functions being
attributes to a single well-known object, that object being the
'string' module, instead of spreading it all over...  So add the
attributes if you wish so (I respect OO minds), but don't zap
the module (i.e. please respect mine ;-).


More information about the Python-Dev mailing list