[Python-Dev] Add transform() and untranform() methods (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Fri Nov 15 15:04:33 CET 2013
- Previous message: [Python-Dev] Add transform() and untranform() methods
- Next message: [Python-Dev] Add transform() and untranform() methods
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, 15 Nov 2013 23:50:23 +1000 Nick Coghlan <ncoghlan at gmail.com> wrote:
My perspective is that, in current Python, that is the right thing for people to do, and any hypothetical new API proposed for Python 3.5 would do nothing to change what's right for Python 3.4 code (or Python 2/3 compatible code). I also find it bizarre that several of those arguing that this is too niche a feature to be worth refining are simultaneously in favour of a proposal to add new *methods on builtin types* for the same niche feature.
I am not claiming it is a niche feature, I am claiming codecs.encode() and codecs.decode() don't solve the use case like the .transform() and .untransform() methods do.
(I do think it is a nice feature in Python 2, although I find myself using it mainly at the interpreter prompt, rather than in production code)
As noted earlier in the thread, Armin Ronacher has been the most vocal of the users of this feature in Python 2 that lamented it's absence in Python 3 (see, for example, http://lucumr.pocoo.org/2012/8/11/codec-confusion/), but I've also received plenty of subsequent feedback along the lines of "what he said!" (such as http://bugs.python.org/issue7475#msg187630).
The way I read it, the positive feedback was about .transform() and .untransform(), not about recommending people switch to codecs.encode() and codecs.decode().
Rather than the more useful:
>>> b"abcdef".decode("hex") Traceback (most recent call last): File "", line 1, in TypeError: 'hex' decoder returned 'bytes' instead of 'str'; use codecs.decode() to decode to arbitrary types
I think this may be confusing. TypeError seems to suggest that the parameter type sent by the user to the method is wrong, which is not the actual cause of the error.
Regards
Antoine.
- Previous message: [Python-Dev] Add transform() and untranform() methods
- Next message: [Python-Dev] Add transform() and untranform() methods
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]