Skip to content

Old python tools in PYTHON_codes_and_scripts: Minimal python3 compatibility ensured

Nicolas Mounet requested to merge old_libs_python3_compatible into master

Although this part of the code (the "old" python tools) will ultimately disappear (replaced by the new Python interface currently developed, as well as the PyWIT code, which are both python3-compatible from the start), this MR is needed to ensure that other codes like DELPHI which are still using this module, can be made python3 compatible.

No functionality has been changed (except for a new print_warning option - True by default - added to the add_impedance_wake function).

Most of the changes come from the 2to3 utility, and include:

  • print statements (parentheses, and print >> to a file replaced by write),
  • list(...) added when using map, range and .items(),
  • split and replace functions (from string module), replaced by the corresponding methods of str objects,
  • commands replaced by subprocess.

NOTE: The code is still python2 compatible (and tested with the LHC impedance model).

WARNING: Some bugs may remain with python3, but at least the code can now be imported from a python 3 script without failing.

Edited by Nicolas Mounet

Merge request reports

Loading