i recently started python and i wanna learn how to implement modules in my program, but when ever i try to string modules together it says function not callable how do u make functions callable and if u cant then how would u put this code

'readTextfile.py--reads and displays text files'

def opener():
    #get filename:'

    fname = raw_input('enter filename: ')
    print

    #attempt to open a file for reading
    try:
        fobj =open(fname, 'r')
    except IOError, e:
        print"**** file open errpr:", e
    else:
        # display contents on screen
        for eachline in fobj:
            print eachline,
        fobj.close()

along with 3 other ones in a program via importing modules.

Edited 3 Years Ago by mike_2000_17: Fixed formatting

sorry mixed up on the tags

'readTextfile.py--reads and displays text files'

def opener():
    #get filename:'

    fname = raw_input('enter filename: ')
    print

    #attempt to open a file for reading
    try:
        fobj =open(fname, 'r')
    except IOError, e:
        print"**** file open errpr:", e
    else:
        # display contents on screen
        for eachline in fobj:
            print eachline,
        fobj.close()

If you want to run this program file by itself, put the following at the bottom. You can then run the program from the command line with "python program_name". Take a look at the "Starting Python" thread at the top of this forum.

if __name__ == "__main__":
   opener
This article has been dead for over six months. Start a new discussion instead.