Guido van Rossum <guido@digicool.com> writes: > > I've just checked in a set of patches which implement the new > > .decode() method along with a couple of useful codecs. > > Cool! Indeed. Good idea, Marc! This is a bit unfriendly though: >>> "bobbins".encode("gzip") Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/local/src/python/dist/build/Lib/encodings/__init__.py", line 59, in search_function raise SystemError,\ SystemError: module "encodings.gzip" failed to register I thought SystemErrors shouldn't ever happen (isn't it what gets raised for an illegal opcode, for example?). > > To see just how easy it is to write codecs, please have > > a look at the string codecs I added in this patch (e.g. > > zlib_codec.py or hex_codec.py). I am pretty sure that there > > are a lot more useful things in the standard lib which could > > benefit from these easy-to-use interfaces. > > As an excercise, I added a quoted-printable codec. It was easy > indeed! urlencode would be nice. Maybe re.escape, too. html entities? That's probably a bigger can of worms, but print "<p>%s</p>"%text.encode("html") seems delightfully simpleminded. Cheers, M. -- GAG: I think this is perfectly normal behaviour for a Vogon. ... VOGON: That is exactly what you always say. GAG: Well, I think that is probably perfectly normal behaviour for a psychiatrist. -- The Hitch-Hikers Guide to the Galaxy, Episode 9
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4