I am trying to run an other file in the same folder, by using a variable as the name of the file. But it always tells me, that its invalid.
name = File
import name
What do i have to add, that it detects, that this is a variable?
I am trying to run an other file in the same folder, by using a variable as the name of the file. But it always tells me, that its invalid.
name = File
import name
What do i have to add, that it detects, that this is a variable?
If your file is a py file and the file in the same directory. Just import file
or if it is in subdirectory import folder.file
or if you just want to import a variable or a function from file import some_variable
or from folder.file import some_variable
or import everything from file import *
If your file not a py file you have to open the file according to file type. You can not use import