[Python-ideas] Idea: Importing from arbitrary filenames
Nick Coghlan
ncoghlan at gmail.com
Sun Apr 15 03:20:31 EDT 2018
On 15 April 2018 at 17:12, Nick Coghlan <ncoghlan at gmail.com> wrote:
> If you want to do this dynamically relative to the current module,
> then it's possible to do:
>
> global __path__
> __path__[:] = (some_directory, some_other_directory)
> custom_mod = importlib.import_module(".name", package=__name__)
Copy and paste error there: to make this work in non-package modules,
drop the "[:]" from the __path__ assignment.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list