[Python-3000] PEP 3138- String representation in Python 3000 (original) (raw)
M.-A. Lemburg mal at egenix.com
Wed May 14 19:24:11 CEST 2008
- Previous message: [Python-3000] PEP 3138- String representation in Python 3000
- Next message: [Python-3000] PEP 3138- String representation in Python 3000
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2008-05-14 18:33, Georg Brandl wrote:
M.-A. Lemburg schrieb:
In summary, I'd just like to see the following happen:
* revert the type restrictions on the PyCodec* API * enforce the restrictions on the .encode() and .decode() methods of PyUnicode and PyString objects (str and bytes) * add a way to PyUnicode and PyString objects (str and bytes) to allow same type encoding and decoding +1 Will this get use the hex, base64 etc. "codecs" back? If yes, great!
I suppose so :-)
Those would work only work on bytes, though, so to convert the result into text, you'd have to do:
text = bytes.encodebytes('hex').decode('ascii') bytes = text.encode('ascii').decodebytes('hex')
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.strencode() -> str str.strdecode() -> str bytes.bytesencode() -> bytes bytes.bytesdecode() -> 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
-- Marc-Andre Lemburg eGenix.com
Professional Python Services directly from the Source (#1, May 14 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
- Previous message: [Python-3000] PEP 3138- String representation in Python 3000
- Next message: [Python-3000] PEP 3138- String representation in Python 3000
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]