Python Forum
Understanding Python's Import Engine
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Understanding Python's Import Engine
#1
Hi,

I have a question pertaining to importing post python 3.4 (I am using python 3.8). It is my understanding that the import engine will internally invoke meta path finders in sys.meta_path, of which the third PathFinder is used to find modules using sys.path. Given the following file structure, with "test" and "a" being namespace packages,

example/test/a/b.py

If I run an interpreter with cwd as example, the following code fails:
>>> import test.a
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'test.a'


My question is, since the test builtin does not have a module "a", why does the third PathFinder fail to find the module, as the FileFinder with cwd should be able to locate the module?
Reply


Messages In This Thread
Understanding Python's Import Engine - by MysticaL - Feb-07-2020, 10:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  updating pip, python - understanding terminal and pycharm. endlessnameless 0 1,362 Jun-24-2024, 05:48 AM
Last Post: endlessnameless
  Python trivial endgame engine is not working as expected max22 0 1,224 Feb-24-2024, 04:41 PM
Last Post: max22
  Understanding venv; How do I ensure my python script uses the environment every time? Calab 1 5,551 May-10-2023, 02:13 PM
Last Post: Calab
  New to python/coding Need help on Understanding why this code isn't working. Thanks! mat3372 8 3,785 May-09-2023, 08:47 AM
Last Post: buran
  Understanding Python classes PythonNewbee 3 2,289 Nov-10-2022, 11:07 PM
Last Post: deanhystad
  Understanding Python super() for classes OmegaRed94 1 2,525 Jun-09-2021, 09:02 AM
Last Post: buran
  Search Engine nman52 1 83,240 Dec-16-2020, 11:46 AM
Last Post: Larz60+
  problem python search engine forumpy 0 2,191 Sep-15-2020, 10:26 PM
Last Post: forumpy
  Better Understanding Of Object Orientation In Python JoeDainton123 3 3,772 Aug-30-2020, 02:49 PM
Last Post: deanhystad
  Voynich search engine in python using dashes & dot totals to find Italian words Pleiades 3 4,674 Oct-10-2019, 10:04 PM
Last Post: Pleiades

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020