[Distutils] [Python-Dev] PEP 365 (Adding the pkg_resources module)

Paul Moore p.f.moore at gmail.com
Wed Mar 19 19:41:44 CET 2008


On 19/03/2008, Phillip J. Eby <pje at telecommunity.com> wrote:
> So that future PEP 302 importers can define support for these
>  features, please use
>  pkgutil.simplegeneric to implement these, following the pattern set
>  out by other pkgutil functions.  E.g.:
>
>      def resource_listdir(package, resource_name):
>          return loader_listdir(get_loader(package), package, resource_name)
>
>  Where 'loader_listdir' is a simplegeneric with default handlers
>  registered for the built-in/stdlib loader types (zipimporter, None,
>  and ImpLoader).
>
>  If you do this, then new importer/loader types can use
>  loader_listdir.register() to support the functionality, without
>  monkeypatching or other hacks.

If I did this, I'd certainly make sure it was possible for other
loaders to add their own implementations. But I'm not sure I want to
get involved in the generic-function politics involved in using
pkgutil.simplegeneric - particularly as it's undocumented. I may just
go for a simple registry of implementation classes. Sorry, but if you
couldn't get sufficient agreement to simplegeneric to get it in a
"proper" location, I doubt I'd fare better, (Of course, if Guido pipes
up with support for using simplegeneric, I'll go with that - and
document it, and propose that it gets moved to a sensible location.
But I don't want to be the one to try to persuade Guido...)

Paul


More information about the Distutils-SIG mailing list