Closed cclauss closed 6 years ago
Hi @cclauss, thanks for your interest!
In my opinion, the best way to provide both python 2 and 3 compatibility is to use the six library or consider rewriting the code to be version-agnostic. I don't think that automatic replacement is a good option for now.
We'll create a feature-request list and try to fulfill the most popular requests.
I too prefer the six approach but I often find that people are resistant to adding an additional dependency. I have modified the PR to use six instead of try/except blocks.
Great, six approach is much better, thanks :) We don't have enough tests yet, so I think we need to take a time to fully test your PR because it's a global modification.
I hope we'll return to this PR as everything will be properly tested.
Hi, @cclauss Thank you for your PR.
Unfortunately, the current version of the code is not compatible with Python 3.
There are still some imports that should be done from six
package. For example:
https://github.com/cclauss/cakechat/blob/modernize-python2-code/cakechat/dialog_model/model_utils.py#L3
You can test that everything is working by running python bin/cakechat_server.py
under Python 3.
Can you please fix this and update the PR?
Thank you
Closed in favor of #10
Make the minimal, safe changes required to convert the repo's code to be syntax compatible with both Python 2 and Python 3. There may be other changes required to complete a port to Python 3 but this PR is a minimal, safe first step.
Run: futurize --stage1 -w */.py
One change that I was not so sure about was the change of a ur'string' to be just a u'string'. In Python 3, you can have u'strings' or r'strings' but ur'strings' are a syntax error.