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

Nick Coghlan ncoghlan at gmail.com
Wed May 14 23:39:00 CEST 2008


M.-A. Lemburg wrote:
> On 2008-05-14 18:33, Georg Brandl wrote:
>> M.-A. Lemburg schrieb:
>>> Fine, so we need new methods for PyUnicode and PyString objects
>>> which allow encoding and decoding using the same type (and enforce
>>> the return types).
>>>
>>> Any suggestions ?
>>>
>>> How about these:
>>>
>>> str.str_encode() -> str
>>> str.str_decode() -> str
>>>
>>> bytes.bytes_encode() -> bytes
>>> bytes.bytes_decode() -> bytes
>>
>> Cool, a naming contest :)
>>
>> What about transform/untransform?
> 
> Not bad :-)
> 
> Here's a version without underscores:
> 
> str.encodestr() -> str
> str.decodestr() -> str
> 
> bytes.encodebytes() -> bytes
> bytes.decodebytes() -> bytes

A couple more possibilities (Guido is probably going to have to choose a 
colour for this bikeshed somewhere along the line...):

mystr.recodeto('unicode-escaped')
mystr.recodefrom('unicode-escaped')

mybytes.recodeto('hex')
mybytes.recodefrom('hex')

Cheers,
Nick.

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


More information about the Python-3000 mailing list