M.-A. Lemburg wrote: > Now that more and more codecs become available and the scope > of those codecs goes far beyond only encoding from Unicode to > strings and back, I am tempted to open up that restriction, > thereby opening up u.encode() for applications that wish to > use other codecs that return e.g. Unicode objects as well. > [...] > Note that codecs are not restricted in what they can return > for their .encode() or .decode() method, so any object > type is acceptable, including subclasses of str or > unicode, buffers, mmapped files, etc. +1. I find it surprising that the restriction exists. I would have thought u.encode('foo') would pretty transparently wrap the foo codec's .encode(). This is also a good reminder that type checking of the result of codec or unicode .encode() calls is prudent, anytime.
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