[Python-3000] PEP 3138- String representation in Python 3000

Nick Coghlan ncoghlan at gmail.com
Thu May 15 15:42:24 CEST 2008


M.-A. Lemburg wrote:
> The .transform() methods would simply check for the corresponding
> type combination, ie. str.transform() would check for (str, str).
> str.encode() would check for (str, bytes), bytes.decode() for
> (bytes, str).
> 
> Alternatively, we could just not check the type combinations
> at all and only apply the result type check.
> 
>> 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.
> 
> I'm not sure I understand.

If we went with the approach of checking type annotations on the codec, 
then would a codec which was only annotated with (bytes, str) on the 
decode method be usable by bytearray.decode()?

And if we aren't going to check the type annotations before invoking the 
codec, what's the point in having them at all? Better to leave them out 
entirely, invoke the relevant method of the named codec and see if we 
get the right type back.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-3000 mailing list