Python Forum
where module is loaded from
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
where module is loaded from
#2
(Jul-25-2023, 10:03 PM)Skaperen Wrote: have a module with some code inside that needs to know what exact file path it was loaded from.
Use
__file__
or almost equivalently
__spec__.origin
In order to reliably aggregate data files to a Python package, it is better to use importlib.resources. Also read setuptools' data files support.
Skaperen likes this post
Reply


Messages In This Thread
where module is loaded from - by Skaperen - Jul-25-2023, 10:03 PM
RE: where module is loaded from - by Gribouillis - Jul-26-2023, 05:38 AM

Forum Jump:

User Panel Messages

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