Skip to content

f-string syntax error with Python 3.11 #51

@sam-grant

Description

@sam-grant

Our main analysis environments use Python 3.12, but the special trkqual environments use Python 3.11.

In 3.11, you have to be more careful with nested quotations. In particular, this line in pyplot will throw an exception:

https://github.com/Mu2e/pyutils/blob/main/pyutils/pyplot.py#L40

Python 3.11.14 | packaged by conda-forge | (main, Oct 22 2025, 22:46:25) [GCC 14.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyutils.pyplot import Plot
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/exp/mu2e/data/users/sgrant/pyenv/env/trkqual_v1.0.0/lib/python3.11/site-packages/pyutils/pyplot.py", line 40
    self.logger.log(f"Initialised Plot with {self.style_path.rsplit("/", 1)[-1]} and verbosity = {self.verbosity}", "info")
                                                                     ^
SyntaxError: f-string: unmatched '('

This is easy to fix!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions