Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.5 compatibility #24

Open
andjelx opened this issue Feb 1, 2017 · 6 comments
Open

Python 3.5 compatibility #24

andjelx opened this issue Feb 1, 2017 · 6 comments

Comments

@andjelx
Copy link

andjelx commented Feb 1, 2017

Seems library not 100% python3 compatible. When I'm tying to run simple code:

import doc2text

doc = doc2text.Document()
doc = doc2text.Document(lang="eng")
doc.read('pdf-sample.pdf')

I'm getting

Traceback (most recent call last):
  File "doc2text_test.py", line 13, in <module>
    doc.read('pdf-sample.pdf')
  File "/usr/local/lib/python3.5/dist-packages/doc2text/__init__.py", line 44, in read
    for i in xrange(self.num_pages):
NameError: name 'xrange' is not defined
@andjelx
Copy link
Author

andjelx commented Feb 1, 2017

Pull request #25 created

@neel17
Copy link

neel17 commented Dec 19, 2018

Need to change the code in file init.py
Line 44:
` for i in xrange(self.num_pages): '

to

for i in list(range(self.num_pages)):

@andjelx
Copy link
Author

andjelx commented Dec 19, 2018

@neel17 xrange returns itterator, not list - which is more optimal in terms of mem usage.

@neel17
Copy link

neel17 commented Dec 19, 2018

@andjelx xrange is not supported in Python3, what could be the probable work around?

@andjelx
Copy link
Author

andjelx commented Dec 19, 2018

@neel17 Have u ever checked the PR?

@neel17
Copy link

neel17 commented Dec 19, 2018

@andjelx : My regret, your PR works fine, I was trying to solve it and got this issue resolve using the above solution as well.
Thanks for making me re-understand it again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants