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.

Recommended Answers

All 2 Replies

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.