[Python-3000] PEP 3138- String representation in Python 3000
Nick Coghlan
ncoghlan at gmail.com
Thu May 15 13:01:41 CEST 2008
M.-A. Lemburg wrote:
> I'll write up a PEP once we have a better understanding of the
> details, e.g. of how the codec type information should be
> defined...
>
> Here's a straight-forward approach:
>
> codecinfo.encode_type_combinations = [(bytes, bytes), (str, str)]
> codecinfo.decode_type_combinations = [(bytes, bytes), (str, str)]
>
> for most codecs (e.g. utf-8, latin-1, cp850, etc.) this would
> then be:
>
> codecinfo.encode_type_combinations = [(str, bytes)]
> codecinfo.decode_type_combinations = [(bytes, str)]
Do we need something that flexible? Would a simpler approach with
separate "binary_transform" and "text_transform" flags be enough?
With the latter approach, the encode()/decode() methods could complain
if either of the transform flags was set on the codec, while the
transform()/untransform() methods could complain if the appropriate
transform flag *wasn't* set.
Note also that both bytearray and bytes provide decode() methods, and
will presumably provide transform() methods, so actual type annotations
may not be the best way to go about this.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-3000
mailing list