We introduced the option to choose to use Aimsun Next with Python 3 in the latest version, Aimsun Next 20. However, there are some important differences to be aware of between Python 2 and Python 3 when you begin to convert your models and scripts. This technical note will cover the key differences and how to update your Python 2 script to get it Python 3–ready.
In January 2020, Python 2 reached end–of-life status, which means it will receive no further updates or bug fixes and, importantly, no security fixes. We therefore recommended that you use Python 3 for all new development. A lot of Python 3 code in Aimsun software is useable also in Python 2. However, you may find that your old script gives errors when used with Python 3 – particularly with respect to print statements!
In addition to print statements, it’s good to be aware of the major differences so you can check what needs to be changed if you did wish to use the same script or cost function on multiple models as some changes may change your script without giving an error.
Print
The most common change you will see is with print statements. In Python 3, the print statement should be in brackets.