I want to add some text to a file name before the extension. Example: name.ext
>>> name_su.ext
.
I can do it with traditional python string formatting:
filename = 'name.ext'
suffix = '_su'
print("{0}{2}{1}".format(*os.path.splitext(filename) + (suffix, )))
# This will print: name_su.ext
I wonder if I can achieve the same with f-string notation, in a single line, without calling os.path.splitext(filename)
twice.