Skip to content

Conversation

@codejoust
Copy link

Updating the utility to work with python3, mainly needed for updated sqlite on osx (otherwise get 'database encrypted error).

@toffer
Copy link
Owner

toffer commented Jun 17, 2012

Is the idea to have 2 separate scripts in the repository: one for python2 and one for python3?

@codejoust
Copy link
Author

That, or if statements could be put into the original script.

That's probably a better solution.


Iain Nash

El Jun 17, 2012, a las 14:27, Tom Offermann reply@reply.github.com escribió:

Is the idea to have 2 separate scripts in the repository: one for python2 and one for python3?


Reply to this email directly or view it on GitHub:
#6 (comment)

@toffer
Copy link
Owner

toffer commented Jun 17, 2012

I haven't worked with python3 at all, so this may be a dumb question...

To write a single script that works with python2 and python3, is the usual technique to use if statements? So, the script would have an if statement like this every time there's a difference between the two (like print, or handling unicode):

if sys.version < '3':  # python2
  do this
else:                  # python3
  do that

@codejoust
Copy link
Author

I took inspiration from bottle.py (https://raw.github.com/defnull/bottle/master/bottle.py) and redid the pull with ifs.

Most of the issue was that strings by default are now unicode so str.decode() is unnecessary / doesn't work, along with switching the print statements.

I can't fully test the python 2.7 script on my machine due to an older version of the sqlite binaries in my osx python distribution, but it runs up until fetching from the database fine.

@toffer
Copy link
Owner

toffer commented Jun 17, 2012

OK. Thanks for this. I like the idea of a single file much better, so let me look this over and do some testing before merging.

@codejoust
Copy link
Author

No problem.
Thanks for looking into this!

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

Successfully merging this pull request may close these issues.

2 participants