Can a string method, such as .rjust(), be saved in a variable and applied to a string?
Looked here but could not find a solution.
For example, instead of stating rjust(4, '-')
twice, can it be coded once in a variable and then passed to the two strings?
# Instead of this
print("a".rjust(4, '-'),
"xyz".rjust(4, '-'),
sep="\n")
# Something like this?
my_fmt = rjust(4, '-')
print("a".my_fmt,
"xyz".my_fmt,
sep="\n")
Both result in:
---a
-xyz