summaryrefslogtreecommitdiffstats
path: root/Doc/whatsnew
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2010-12-05 04:04:21 (GMT)
committerRaymond Hettinger <python@rcn.com>2010-12-05 04:04:21 (GMT)
commit43b5a857d62eb56ed14887acd8fce2f32c915d2e (patch)
tree575343119cfbbf48828eb6a4aa308e0e0e4b44eb /Doc/whatsnew
parentdadf93c9104385aa3f88c64b73ce668a035e00d2 (diff)
downloadcpython-43b5a857d62eb56ed14887acd8fce2f32c915d2e.zip
cpython-43b5a857d62eb56ed14887acd8fce2f32c915d2e.tar.gz
cpython-43b5a857d62eb56ed14887acd8fce2f32c915d2e.tar.bz2
Describe the transform/untranform methods
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r--Doc/whatsnew/3.2.rst19
1 files changed, 19 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.2.rst b/Doc/whatsnew/3.2.rst
index f840113..dac2bec 100644
--- a/Doc/whatsnew/3.2.rst
+++ b/Doc/whatsnew/3.2.rst
@@ -298,6 +298,25 @@ Other Language Changes
Some smaller changes made to the core Python language are:
+* :class:`bytes` and :class:`str` now have two net methods, *tranform* and *untransform*.
+ These provided analogues to *encode* and *decode* but are used for general purpose
+ string-to-string and bytes-to-bytes transformations rather than Unicode codecs.
+
+ Along with the new methods, several non-unicode codecs been restored from Python 2.x
+ including *base64*, *bz2*, *hex*, *quopri*, *rot13*, *uu*, and *zlib*.
+
+ >>> t = b'which witch had which witches wrist watch'
+ >>> t.transform('quopri')
+ b'which=20witch=20had=20which=20witches=20wrist=20watch'
+
+ >>> short = t.transform('zlib_codec')
+ >>> len(t), len(short)
+ (41, 38)
+ >>> short.untransform('zlib_codec')
+ b'which witch had which witches wrist watch'
+
+ (From multiple contributers in :issue:`7475`.)
+
* The interpreter can now be started with a quiet option, ``-q``, to suppress
the copyright and version information in an interactive mode.