Hello,

On Tue, 8 Dec 2020 07:29:15 -0300
"Joao S. O. Bueno" <jsbu...@python.org.br> wrote:

> And how would Python compute the "full basename of the file to be
> imported"?

The way it does it usually.

> How could it guess among all directories on sys.path the one
> containing the "file", and check if it is a file or a package without
> going through the existing mechanism?

It would not guess anything, it would iterate thru sys.path, as it
usually does, and would give the hook a chance to see if the needed file
exists.

This proposal is also about *modules* and treats packages just as
"hierarchical structure of modules" (Python does more than that, but
this is "dead simple import hooks").

> Maybe this proposal is good - but possibly,  just cutingt the "full
> basename" and pass
> to the "simple hook" whatever string is on the import statement would
> be better.

That's already possible, just hook into __import__() (or one of the
other extension points provided by importlib). It's exactly the
"convert full hierarchical module name into the actual file path"
what's the boring part of it, and what I want to leave to the existing
import system.

[]

-- 
Best regards,
 Paul                          mailto:pmis...@gmail.com
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/BKNB3GRSKJZHBX5LUBBIFJJZ25I3PRQ7/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to