[Python-Dev] Add transform() and untranform() methods (original) (raw)
Facundo Batista facundobatista at gmail.com
Fri Nov 15 13:58:05 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 Thu, Nov 14, 2013 at 7:32 PM, Victor Stinner <victor.stinner at gmail.com> wrote:
I would prefer to split the registry of codecs to have 3 registries:
- "encoding" (a better name can found): encode str=>bytes, decode bytes=>str - bytes: encode bytes=>bytes, decode bytes=>bytes - str: encode str=>str, decode str=>str And add transform() and untransform() methods to bytes and str types. In practice, it might be same codecs registry for all codecs just with a new attribute.
I like this idea very much.
But to see IIUC, let me be more explicit... you'll have (of course, always py3k-speaking):
bytes.decode() -> str ... here you can only use unicode encodings
no bytes.encode(), like today
bytes.transform() -> bytes ... here you can only use things like zlib, rot13, etc
str.encode() -> bytes ... here you can only use unicode encodings
no str.decode(), like today
str.transform() -> str ... here you can only use things like... like what?
When to use decode/encode was always a major pain point for people, so doing this extra separation and cleaning would bring more clarity to when to use what.
Thanks!
-- . Facundo
Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/ Twitter: @facundobatista
- 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 ]