-
Notifications
You must be signed in to change notification settings - Fork 117
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.
- 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
- PREFER STL vectors or RVecs over TVectorT
- PREFER STL containers or RTensor over TMatrix