Newbie question, can’t get my head around it. When I use these 3 lines of code:
with open('result.csv', mode='a+', newline='') as result:
writer = csv.writer(result)
at the end of a small program, I get this error: “TypeError: ‘int’ object is not callable”. When I run the 3 lines of code seperately in a Jupyter cell, it works sometimes but not always? I am trying to append a few variables to a new row of a csv. What’s happening? Thx!!
Adding the statement
a, b, c = 1, 2, 3 in front of your code, this works over here.
Could you post a minimal code demonstrating the failure as well as the complete error traceback? (See About the Users category in case you’re unsure how to format these.)
You might also want to try with an empty CSV file. Attach the one you are using if the error does not reproduce then.
Found it, I made an embarrasing stupid mistake. I used the word ‘open’ as a variable somewhere in the program. Thanks for your prompt reply!
This is why you should ALWAYS include the FULL ERROR MESSAGE, not just a snip of the last line.
Had you put in the FULL ERROR MESSAGE, we can immediately see that the error would be on the line
ALWAYS include the FULL ERROR MESSAGE, not just a snip of the last line.
…and remember that the first error message, not the last one, is usually what triggered the code fault(s).
And it’s often the code that executed right before the first error message popped up that’s the root source of the error.