I wouldn’t pick it, but as well as reusing the syntax for f-string and format string fields, technically that placeholder is a perfectly valid directory name already:
debian@...:~$ ls /tmp/dir -la
total 12
drwxrwxr-x 3 debian debian 4096 Jan 16 13:36 .
drwxrwxrwt 10 root root 4096 Jan 16 13:36 ..
drwxrwxr-x 2 debian debian 4096 Jan 16 13:36 {LATEST_BY_NAME}
Have you tried something like?:
subdirs = [p for p in Path('dir').iterdir() if p.is_dir()]
latest = max(subdirs, key = lambda p: p.name)
So the key function needs to be defined more carefully than Path.name, to convert digits to an int.
Also, pathlib already does text pattern matching (albeit without full Regex capture objects). Doesn’t Path('.').glob('dir/v*/file.json') return all the required files?