To find the complete information about the changes in Python 3.x, you can read the "What's new
" page for each release of Python 3 and the Porting to Python 3
Running migration script
A migration script python3_migration.py
is provided in Simcenter Amesim (located in $AME/scripting/python) to help porting Python scripts to Python 3 (the script internally uses the lib2to3
library).usage: python3_migration.py [-h] [--no-backup] [--logfile [FILE]] [-v] path
The path argument can be either a directory, a Python script or an App file (*.app).
Disable the file backup. By default, a backup of the original file is done.--logfile <file>:
Create a log file with the given filename (no log file by default).-v, --verbose:
Increase the verbosity. When enabled, it will log more information (disabled by default).
Here is a basic example of porting the content of python_scripts directory recursively, and logging conversion outputs into migration_log.txt file:python -m python3_migration --logfile migration_log.txt python_scripts
In Simcenter Amesim, when editing an App created in a previous version in App Designer, the user is asked whether he wants to automatically convert the code to Python 3.
By answering "Yes", the App Designer will execute automatically the migration script on the App Python scripts. The user can also consider to convert his code manually by discarding the automatic migration.