[Tutor] Alternative to importing

Mats Wichmann mats at wichmann.us
Sun Oct 3 17:24:40 EDT 2021


On 10/3/21 09: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?

so... @dn gave you some ideas.

but it's really hard not to ask: what is it you're trying to accomplish?

importing is an absolutely fundamental part of Python.  when somebody 
wants to avoid import statements it seems fair to try and look behind 
the curtain: there's some reason you're asking this question, right?


oh, one more fun resource for you:

https://tenthousandmeters.com/blog/python-behind-the-scenes-11-how-the-python-import-system-works/



More information about the Tutor mailing list