As mentioned by others, -
in name is invalid, try importing after removing them if you have them in your file name. For now, let's call it program_to_import
from folder import program_to_import
And to call a function from program_to_import
, you use this -
program_to_import.function_to_call()
Also, it's always a good idea to look at the documentation
You could also try by adding an __init__.py
in your folder. The use of __init.py__
is as follows -
The init.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string, from unintentionally hiding valid modules that occur later (deeper) on the module search path. In the simplest case, init.py can just be an empty file, but it can also execute initialization code for the package or set the all variable, described later.