[Python-ideas] Query available codecs and error handlers
Steven D'Aprano
steve at pearwood.info
Fri Aug 29 10:16:15 CEST 2014
On Fri, Aug 29, 2014 at 09:33:47AM +0200, M.-A. Lemburg wrote:
> On 29.08.2014 07:45, Steven D'Aprano wrote:
> > Unless I am badly misinformed, there is no way to programmatically check
> > what codecs and error handlers are available. I propose two functions in
> > the codecs module:
> >
> > get_codecs()
> > get_error_handlers()
> >
> > which each return a set of the available codec, or error handler, names.
>
> Question is: how would you implement these ?
>
> The codec registry uses lookup functions to find codecs, so we'd
> have to extend those lookup functions to also support reporting
> known installed codecs.
Arrgggh, you're right -- I've been working on a wrong assumption. I had
forgotten that the codecs.register function takes a function, not a
name.
I always forgot that, because it's such a strange and unhelpful API
compared to, say, a mapping of name:codec. It's probably water under the
bridge now, but is there any documentation for why this API was used in
the first place?
--
Steven
More information about the Python-ideas
mailing list