Hi everyone,

I've been researching various python libraries to extract data from pdf files.

Currently, I'm exploring PyMuPDF

After installing it, I try to run a basic script to get the number of pages in the pdf file.

However, the following runtime error occurs.

File "/usr/local/apps/PyMuPDF-1.18.17/fitz/fitz.py", line 1281
def is_rectangular(self) -> bool:                           
SyntaxError: invalid syntax

Can anyone explain what that -> operator is?


Recommended Answers

I'm comparing your line 2 with line 806 at https://github.com/pymupdf/PyMuPDF/blob/master/fitz/helper-geo-py.i and no match.
That is, you appear to have added a few spaces.

Jump to Post

All 4 Replies

It may be that the error message that appeared on my terminal wasn't pasted in exactly into the Daniweb message entry area.
That may be the reason why a match wasn't found

So, after much searching, it seems that -> has something to do with a concept called 'type hinting'.
If I recall correctly, this was in python version 3.5

The syntax error is correct for my installation.
I have python 2.7.12 installed.

Thanks for the reply.

As stated earlier, -> is indeed type hinting. For example, if you define a method that takes a string parameter and returns a boolean you can define it lie

def myFunc(name):


def myFunc(name:str) -> bool:

It is strictly for informational purposes.

commented: Not going to lie, with Python I rarely check Python versions as at office and elsewhere we don't use old (Python) versions. +16
Be a part of the DaniWeb community

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