Zulko / easyAI

Python artificial intelligence framework for games
http://zulko.github.io/easyAI/
Other
639 stars 126 forks source link

Port to Python3 #38

Closed nealmcb closed 5 years ago

nealmcb commented 5 years ago

SInce this looks like such a cool project, but support for Python 2 (including security bugs) is going away at the end of the year, this should be ported to Python 3.

Currently, at least the examples fail, e.g. with

File "example.py", line 16
    def show(self): print "%d bones left in the pile"%self.pile
                                                    ^
SyntaxError: invalid syntax

Besides that, Python 3 is a better language, and all the major libraries support it now.

Check out the background and a nice timeline diagram at http://www.python3statement.org/

Great advice, planning process, tips at at Porting Python 2 Code to Python 3

To make your project be single-source Python 2/3 compatible, the basic steps are:

  1. Only worry about supporting Python 2.7
  2. Make sure you have good test coverage (coverage.py can help; pip install coverage)
  3. Learn the differences between Python 2 & 3
  4. Use Futurize (or Modernize) to update your code (e.g. pip install future)
  5. Use Pylint to help make sure you don't regress on your Python 3 support (pip install p\ ylint)
  6. Use caniusepython3 to find out which of your dependencies are blocking your use\ of Python 3 (pip install caniusepython3)
  7. Once your dependencies are no longer blocking you, use continuous integration to make sure you stay compatible with Python 2 &\ 3 (tox can help test against multiple versions of Python; pip install tox)
  8. Consider using optional static type checking to make sure your type usage works in both Python 2 & 3 (e.g. use mypy to check your typing under both Python 2 & Python 3).
Zulko commented 5 years ago

Thanks for the report. In that case, just adding the parenthesis in the example made it python3 compatible.