Skip to content

Python guidelines

Oliver Lantwin edited this page Jan 7, 2025 · 3 revisions

General guidelines to improve the quality and readability of our python code. For python, see the C++ guidelines.

General

  • PREFER iterating over containers to indexing containers manually
  • PREFER argparse over getopt
  • PREFER new style to old style string formatting, see also here
  • ALWAYS use ruff-format (for new code) and ruff-check
  • ALWAYS place import statements at the top of the file
  • NEVER run non-trivial code at the top-level scope of your module, so that it can be imported without side-effects. INSTEAD, hide this code behind an if __name__ == "__main__": condition

FairRoot/FairShip specific

  • PREFER STL vectors or RVecs over TVectorT
  • PREFER STL containers or RTensor over TMatrix
Clone this wiki locally