[Python-Dev] Adding .decode() method to Unicode
Martin v. Loewis
Tue, 12 Jun 2001 00:00:54 +0200
> I would like to add a .decode() method to Unicode objects and also
> enable the builtin unicode() to accept Unicode object as input.
-1. What is this good for?
> While this may seem useless for the currently available encodings,
> it does have some use for codecs which recode Unicode to Unicode,
> e.g. codecs which do XML escaping or Unicode compression.
I still can see the value. If you think the codec API is good for such
transformation, why not use it? I.e.
enc,dec,_,_ = codecs.lookup("compress-form-foo")
s = dec(s)
Furthermore, this seems like a form of hypergeneralization. If you
have this, why not also add
s = s.decode("capitalize") # instead of s.capitalize()
i = s.decode("int") # instead of int(s)
> Any objections ?
Yes, I think this should not be added.