[Tutor] Calling one python module from another

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Fri May 5 23:58:01 CEST 2006



On Fri, 5 May 2006, Mitchel Carlsen wrote:

> Is there an easy way to call on python module (called.py) from another 
> (calling.py)?  I have been able to do this using 'rc = 
> os.system("called.py")' .  Is this the suggested method?

Hi Mitch,

If you are looking for modules, you may want to take a look at a tutorial 
on them.  Here's a link for Alan's tutorial:

     http://www.freenetpages.co.uk/hp/alan.gauld/tutfunc.htm

There's also a section on them from the official Python tutorial:

     http://www.python.org/doc/tut/node8.html

Read those sections first, and you should be able to solve the problem you 
have.  If you have questions, please feel free to ask.


'os.system()' is not ideal for interacting with another Python module, 
since the data channel between separate processes is a bit impovershed and 
uni-directional.  However, one could use os.system() to talk to other 
shell commands besides Python.


More information about the Tutor mailing list