开发者

execute python file from another file

开发者 https://www.devze.com 2022-12-27 10:54 出处:网络
I have a python file that has functions and classes. now I am writting another program (in another file). and I want to start the new file with running the old file (with the function and classes). I

I have a python file that has functions and classes. now I am writting another program (in another file). and I want to start the new file with running the old file (with the function and classes). I have tried using开发者_JAVA技巧 exec(path_2_oldFile.pyw) but it didn't work.

thanks for any help Ariel


Ideally you should try and import the first file into the new as a module using the import statement:

http://effbot.org/zone/import-confusion.htm

You'll need to make sure that your original module is on the python path somewhere. If it is in the same directory as the new file this should just work.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号