[Tutor] Alternative to importing

dn PyTutor at DancesWithMice.info
Sun Oct 3 16:51:51 EDT 2021


On 04/10/2021 04.21, Julius Hamilton wrote:
> Hey,
> 
> Is there any alternative to importing a Python script in another script for
> the methods defined in it, where Python when executing one script will just
> automatically look in the enclosing folder for any other Python scripts,
> and check them for methods? Perhaps there could be a Python option, like
> python -“importall” runscript.py? Or some other way of eliminating import
> statements?

Python's import system is discussed at
https://docs.python.org/3/reference/import.html including the idea of
"packages" which consist of more than one module.

(Judging from previous questions, you may also like to peruse the
previous chapter of that manual: Python's "Execution Model")

More of the actual machinery for handling imports, and the various
sub-components available to advanced-users at
https://docs.python.org/3/library/modules.html which also includes the
various file formats which may be handled.
-- 
Regards,
=dn


More information about the Tutor mailing list