Re: Loading Resources From a Python Module/Package
Nick Coghlan <[email protected]> Mon, 2 Feb 2015 23:22:09 +1000
| Newsgroups | gmane.comp.python.import |
|---|---|
| Message-ID | <CADiSq7eiRyUGUPWpd6ktC7nGfUzL6tDC8xi_LHdVv4xv8+C3qw@mail.gmail.com> |
On 2 Feb 2015 07:43, "Barry Warsaw" <[email protected]> wrote: > > On Jan 31, 2015, at 06:05 PM, Donald Stufft wrote: > > >How about this, instead here’s the top level APIs I want: > >https://bpaste.net/show/0c490aa07c07 < https://bpaste.net/show/0c490aa07c07> > > I like almost all of this. It nicely handles the case where you want a longer > lived file resource (via resource_filename()) and don't care about its life > cycle, and where you want to clean up the resource asap (via > ResourceFilename). > > If I didn't skim over something critical, I think Nick's introduction of the > term "resource anchor" is a useful one. Given that a resource anchor can be > > 1. a string containing the dotted module path to a package > 2. an actual module object > 3. a module spec > > the term better describes the first argument in these APIs than "package". That's the definition of the term I started with, and it's probably the best one. For the related concept used to map this to the underlying import plugin APIs, we can use PEP 451's existing "location" term. > I still would like a generalization of resource_stream() that allows opening > in text mode with a given encoding, I'd prefer a helper function that can be used to easily pass a resource stream to the builtin open() via its opener argument, rather than duplicating that functionality. Regards, Nick. _______________________________________________ Import-SIG mailing list [email protected] https://mail.python.org/mailman/listinfo/import-sig