'Run py file with variable name in jupyter notebook
I am using %run to run a py file from inside a jupyter notebook, but I don't want to edit every time the name of the py file name changes. Is there a way to use $run with a variable filename? Thanks
Solution 1:[1]
I stumbled across this and just in case anyone else does in the future I overcame it via this:
my_changing_string = 'testing_py_file'
exec(open("path_to_file/"+my_changing_string+".py").read())
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | richardec |