Moving from Python 2.7 to 3.x is covered in much more detail here. This list is just a list of items I’m checking as I make the switch. It’s somewhat reflective of my own coding style and is meant more as a checklist for myself than anything, but if it helps you, great!
- Change
printtoprint(). - Change
xrangetorange. - Change
raise, Execption "Message"toraise Exception("Message"). - Change
from module import xtofrom .module import x, ifmoduleis a relative import and not on the PYTHONPATH. If I’m importing the entire module, it’s nowfrom . import module. - Anywhere there is integer division being used, change it from
/to//. - If I use the result of
range(...)as a list, explicitly convert it to a list, e.g.,list(range(...)).