> Samuele Pedroni wrote: > > > I agree with Guido that special cookies can be used for normal > > importers. [Just] > I find this rather ugly, and would only do that if it's crucial that the > pathless importer should be invoked somewhere in the middle of sys.path. > And I don't have a use case for that. There are plenty of use cases for > sys.meta_path. Sure, but pleading for cookies is that they allow easier user control through PYTHONPATH, and/or through sys.path manipulation; cookies allow you to control precisely the import order. It seems they are indeed different features. Once we have path_hooks, cookies are a simple consequence; meta_path is an orthogonal feature. I agree with Samuele's concern that if you have multiple meta_path importers, ordering them may become an issue. On the other hand, ordering of entries in sys.path is a bit of a black art, but in 99% of the cases, insert-in-front or append-at-end seem suffiecient. I expect that the same will be true for sys.meta_path. (Though it would be a bit more convenient if indeed it included the built-in, frozen and path importers -- maybe we can get that done in alpha 2.) I agree with Just that either of these hooks is *much* more convenient than overriding __import__ -- because with __import__, you have to reimplement the whole look-in-sys.path-try-relative-try-absolute-import-parent-packages routine, unless you have a truly trivial use (like printing a log message and calling the real __import__). --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4