Python Forum
Understanding Python's Import Engine
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Understanding Python's Import Engine
#2
example will be the package_name at top level,so you most import from example.
Let say b.py is:
def foo():
    return 42
Import test.
E:\div_code
λ ptpython
>>> import example.test.a.b
>>> example.test.a.b.foo()
42

>>> # Using from
>>> from example.test.a import b
>>> b.foo()
42
For this to work most example folder with sub-folder be in sys.path of Python version used eg i use Python 3.7 here.
Reply


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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python trivial endgame engine is not working as expected max22 0 545 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 2,317 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 1,777 May-09-2023, 08:47 AM
Last Post: buran
  Understanding Python classes PythonNewbee 3 1,214 Nov-10-2022, 11:07 PM
Last Post: deanhystad
  Understanding Python super() for classes OmegaRed94 1 1,852 Jun-09-2021, 09:02 AM
Last Post: buran
  Search Engine nman52 1 56,295 Dec-16-2020, 11:46 AM
Last Post: Larz60+
  problem python search engine forumpy 0 1,746 Sep-15-2020, 10:26 PM
Last Post: forumpy
  Better Understanding Of Object Orientation In Python JoeDainton123 3 2,507 Aug-30-2020, 02:49 PM
Last Post: deanhystad
  Voynich search engine in python using dashes & dot totals to find Italian words Pleiades 3 3,533 Oct-10-2019, 10:04 PM
Last Post: Pleiades
  Making an application with a 3d engine in it moo5e 1 2,129 May-27-2019, 03:17 PM
Last Post: heiner55

Forum Jump:

User Panel Messages

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