I have def myfunc() in script2.py, script3.py, script4.py. In script1.py, I want to call myfunc from script2, script3 and script 4.
In script1.py, rather than tediously listing out:
from script2.py import myfunc
myfunc()
from script3.py import myfunc
myfunc()
from script4.py import myfunc
myfunc()
Is there a way that I can import myfunc from all scripts present in that same directory?
import scriptNthen access withscriptN.myfunc?N? How about if my files were not sharing common prefixes in their name?import scriptNstatements, then you can access eachmyfuncby using a longer name in each case, eg:scriptN.myfunc().import script2, script3, script4and thenscriptN.myfunc()?import script2, script3, script4, then you will need to callscript2.myfunc()orscript3.myfunc()etc.