How do I run a function from a different directory?
When I Import a function from a file in another folder and run it nothing happens. Does anyone know how to fix this without putting them in the same folder?
Voters
RhinoRunner
the reason you got the error is because for is because you did:
from folder.file1 import testdef print(file1.text1) #wrong
since text1
is a local variable inside of testdef
, and you imported testdef
from file1
, you need to do:
from folder.file1 import testdef print(testdef.text1)
i think you just do this.
like that.
Maybe that works.
@RYANTADIPARTHI You are correct, however you need to have the function return the variable before printing it.