Python 2 and Python 3 — Ren'Py Documentation

# Python 2 and Python 3

Ren'Py is adding support for Python 3. The goal is to keep Ren'Py itself compatible with Python 2 for as long as possible, while at the same time supporting Python 3. This is because there are a lot of Ren'Py games written in Python 2, and we'd like to keep supporting them forever, while at the same time supporting Python 3 for new development.

## Version Numbering

The goal is to release two tracks of Ren'Py, with different major version numbers:

Ren'Py 7.x.y
  Will support Python 2.
Ren'Py 8.x.y
  Will support Python 3.

We won't try to keep the two versions in sync; Ren'Py 8.0 might be Ren'Py 7.5 or so.

## Dict

The dictionary class in Python 3 has changed. The .items(), .keys(), and .values() methods now return view objects, rather than lists of objects, and the .iteritems(), .iterkeys(), and .itervalues() methods have gone away. This is a problem, as the brief way to iterate over a dict's items is:

    for k, v in d.items():
        ...

But that's a problem in Python 2, as it has to construct a list. The method proposed by PEP 469, and implemented in six. However, this leads to having to write:

    for k, v in iteritems(d):
        ...

Which doesn't feel Pythonic. The solution that I plan to implement is the one rejected in PEP 469, which is patching the dict class to add the .iteritems(), .iterkeys(), and .itervalues() methods back to the API.