Python - How to call the main fuction of a module in another module?
Question: I am trying to write a python module that calls the main function of another
module in its main function.

The module I am writing is called Trial.py and the module that contains the
function to be called is called `print_all.py` .

print_all.py is a module is a library called mrtparse. The library can be
found [here](https://github.com/YoshiyukiYamauchi/mrtparse).

Note that when I run `print_all.py` in the Linux shell it requires a file
(.gz) as argument as follows

    
    
    $ python print_all.py updates.gz
    

`Trial.py` looks something like this:

    
    
    from mrtparse import *
    import gzip
    import print_all   
    import os
    from urllib2 import urlopen, URLError, HTTPError
    
    def fn1():
        Bla Bla
    
    def fn2():
        Bla Bla
    
    def main():
        mrtparse.print_all.main(updates.gz)  //I want to do something like this
    
    if __name__ == '__main__':
        main()
    

All the modules and the files to be passed as arguments are in the same
directory. It seems like an easy to do thing but I am having such a hard time
with it.


Answer: you could in the script you want to run the main function from place main() in
the else statement instead of if **name** then import it in your script and
just run.

    
    
    if __name__=='__main__':
         pass
    else:
         main()
    

