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 support #10

Closed
ericfrederich opened this issue Aug 9, 2016 · 3 comments · Fixed by #11
Closed

Python 3 support #10

ericfrederich opened this issue Aug 9, 2016 · 3 comments · Fixed by #11

Comments

@ericfrederich
Copy link

There isn't much Python code in this repo at all, just demos really.
The interface is written in Cython which emits code that works with Python 2 or 3.

Because of this, it is trivial to support both 2 and 3 from the same code base.

Just some changes to print statements within the demos, and a simple bytes/strings conversion on the bopt parameters.

@ericfrederich
Copy link
Author

Any word on this? I'd like to see it merged if possible. If there is an issue let me know, I'd be happy to accommodate.

@rmcantin
Copy link
Owner

Thanks Eric. I'll check this, as soon as possible.

Have you tested it in Python 2? I believe print(a,b) -that is, two or more things with a comma- is broken in Python 2.

@ericfrederich
Copy link
Author

@rmcantin , This gets interpreted differently between Py2 and Py3 but does not break anything.

  • In Python3 this is the print function with two arguments to that function
  • In Python2 this is the print statement followed by a tuple of length 2 (even if there is no space between the print and the tuple)

See... they both work fine but get interpreted a bit differently.

$ python3 -c "print(1, 'two')"
1 two
$ python2 -c "print(1, 'two')"
(1, 'two')

If you want the exact same behavior on 2 and 3 you can import print_function from __future__. Though I think this is overkill. The printout is just part of the installation process.

$ python2 -c "from __future__ import print_function; print(1, 'two')"
1 two
$ python3 -c "from __future__ import print_function; print(1, 'two')"
1 two

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 a pull request may close this issue.

2 participants