Jim
Jim

Reputation: 3284

PyPDF's PdfFileReader() having problems reading file, file not callable

So here is my import:

from pyPdf import PdfFileWriter, PdfFileReader

Here is were I write my pdf:

filenamer = filename + '.pdf'
pdf = PdfPages(filenamer)

(great naming convention, I know!)

I write some things to it.

I close it here:

pdf.close()

Here is where I try and read it:

input1 = PdfFileReader(file(filenamer, "rb"))

And here is the error:

Traceback (most recent call last):
  File "./datamine.py", line 405, in <module>
    input1 = PdfFileReader(file(filenamer, "rb"))
TypeError: 'file' object is not callable

I dont understand the error, because I know the file exists, and when I comment out this line, and subsequent lines to input1, the program runs fine.

Upvotes: 1

Views: 4442

Answers (1)

Ned Batchelder
Ned Batchelder

Reputation: 375584

It looks like you've assigned an open file to the name file, and then you can't use the builtin any more.

Upvotes: 4

Related Questions