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

M.-A. Lemburg mal at egenix.com
Thu May 15 11:48:55 CEST 2008


On 2008年05月14日 23:42, Guido van Rossum wrote:
> On Wed, May 14, 2008 at 2:39 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> 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')
>> Nah. I'm still in favor of [un]transform. Let's just stick to that.

Ok, so I'll add
str.transform() -> str (uses the encode function of the codec)
str.untransform() -> str (uses the decode function of the codec)
bytes.transform() -> bytes (uses the encode function of the codec)
bytes.untransform() -> bytes (uses the decode function of the codec)
Is there an easy way to SVN-revive the removed base64, hex, etc
codec modules in encodings ? As far as I remember, I have to look
for the revision just before they were deleted and then "copy" them
from there using the repo URL.
-- 
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, May 15 2008)
 >>> Python/Zope Consulting and Support ... http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::

 eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
 Registered at Amtsgericht Duesseldorf: HRB 46611


More information about the Python-3000 mailing list

AltStyle によって変換されたページ (->オリジナル) /