call py from py

A

Alberto Vera

Hello:

Could you tell me How I Can call a python program from another one?

Regards
 
I

Irmen de Jong

Alberto said:
Could you tell me How I Can call a python program from another one?

Just import the other module and call a function from it?
Or use os.system or whatever.

More info needed for better answers.

--Irmen
 
D

David Fraser

Alberto said:
Hello:

Could you tell me How I Can call a python program from another one?

Regards

If you want to run another python program from within a python program
rather than just calling functions in another module, you can use the
builtin function execfile. help(execfile) gives the details:

Help on built-in function execfile:

execfile(...)
execfile(filename[, globals[, locals]])

Read and execute a Python script from a file.
The globals and locals are dictionaries, defaulting to the current
globals and locals. If only globals is given, locals defaults to it.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,291
Messages
2,571,453
Members
48,137
Latest member
IndiraMcCo

Latest Threads

Top