[Python-Dev] Require loaders set __package__ and __loader__

Barry Warsaw barry at python.org
Mon Apr 16 00:37:36 CEST 2012


On Apr 14, 2012, at 03:32 PM, Guido van Rossum wrote:

>Funny, I was just thinking about having a simple standard API that
>will let you open files (and list directories) relative to a given
>module or package regardless of how the thing is loaded.

I tend to use the "basic resource access" API of pkg_resources.

http://peak.telecommunity.com/DevCenter/PkgResources#basic-resource-access

I'm not suggesting that we adopt all of pkg_resources, but I think the 5
functions listed there, plus resource_filename() (from the next section)
provide basic functionality I've found very useful.

-Barry


More information about the Python-Dev mailing list