Re: Loading Resources From a Python Module/Package
PJ Eby <[email protected]> Sat, 31 Jan 2015 13:00:02 -0500
| Newsgroups | gmane.comp.python.import |
|---|---|
| Message-ID | <CALeMXf4AktJxS0VVAyDmhywWgUYmo+83gyQOSGgNdLmKu87C=Q@mail.gmail.com> |
On Sat, Jan 31, 2015 at 11:13 AM, Donald Stufft <[email protected]> wrote: > To be clear, I think using __name__ is massively better than using __file__, > for one even though PEP 302 states that __file__ must be set, it actually > doesn’t have to be set and PEP 420 doesn’t set it. Even if it did set it > that pattern is only actually really usable for non namespace packages (of > any type). Indeed, pkg_resources does not support resource access from namespace packages, only from specific modules or non-namespace packages contained in a namespace package. In the face of ambiguity, the implementation should refuse to guess. Disallowing namespace-relative access avoids the possibility of ambiguity, and it's essentially a non-issue anyway since there's no real use case for "find me whichever copy of this file got installed first or got listed first on sys.path". _______________________________________________ Import-SIG mailing list [email protected] https://mail.python.org/mailman/listinfo/import-sig