newb: How to call one modue from other

johnny rampeters at gmail.com
Wed Dec 6 19:06:47 EST 2006


I have a module called ftp and I have another module called
processKick.  What I need is to have processKick, create fork and
execute ftp like below.

Relevant processKick code as follows:

def do_child_stuff():
    ftp

def fork_test():
    pid = os.fork()
    if pid == 0:
        # child
        do_child_stuff()
        os._exit(0)
    # parent - wait for child to finish
    os.waitpid(pid, os.P_WAIT)

Can someone also tell me what is the purpose of
if __name__ == "__main__":

Do I have to call, main of ftp module within processKick?

Thank you in advance




More information about the Python-list mailing list