Martin von Loewis wrote: > > > > What user code exactly would break? Would that be a serious problem? > > > > All code which assumes a tuple as return value. It's hard to > > say how much code makes such an assumption. Most Python > > code probably only uses the sequence interface, but the C interface > > was deliberately designed to return tuples so that C programmers > > can easily access the data. > > I believe that code would continue to work if you got a instance of a > tuple subtype. It might work at Python level, maybe even at C level, but I really don't see the point in trying to hack up a new type just for this purpose. Here's an implementation which pretty much solves the "problem": -- ### Helpers for codec lookup def getencoder(encoding): """ Lookup up the codec for the given encoding and return its encoder function. Raises a LookupError in case the encoding cannot be found. """ return lookup(encoding)[0] def getdecoder(encoding): """ Lookup up the codec for the given encoding and return its decoder function. Raises a LookupError in case the encoding cannot be found. """ return lookup(encoding)[1] def getreader(encoding): """ Lookup up the codec for the given encoding and return its StreamReader class or factory function. Raises a LookupError in case the encoding cannot be found. """ return lookup(encoding)[2] def getwriter(encoding): """ Lookup up the codec for the given encoding and return its StreamWriter class or factory function. Raises a LookupError in case the encoding cannot be found. """ return lookup(encoding)[3] -- If noone objects, I'll check these into CVS along with some docs for libcodecs.tex. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/
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