Mohsin Kale
Mohsin Kale

Reputation: 105

TypeError: '_io.TextIOWrapper' object is not callable, creating text file error

    list = [Blarg, T2, T3]
    Rewrite(List)


    def Rewrite(New2):
        List_Length = len(New2)
        L = 0
        with open('Chronologiser2.BCF', 'w') as file_output:
            file_output('')

        while L < List_Length:
            with open('Chronologiser2.BCF', 'a') as file_output:
                Current_Text = New2[L]
                file_output(str(Current_Text) + '/n')
                L += 1

Can someone explain to me why i keep getting the 'TypeError: '_io.TextIOWrapper' object is not callable' error, I've wracked my brain, looked at similair questions but still nothing

Upvotes: 10

Views: 43774

Answers (1)

hiro protagonist
hiro protagonist

Reputation: 46881

you need to call the write method of file_output, not call it directly:

file_output.write('')

Upvotes: 13

Related Questions