I would like to output something like:
===>>> [FINISHED] Building sources: bla (1h:20m:30s)
===>>> [FINISHED] Building sources: The brown fox jumped... (7h:05m:00s)
That is, a string filling a width of N
characters, with a first part left-aligned, and a second part right-aligned.
I have a print
in a function and I just want to get an easy-to-read output. At the end of the execution of the script, I will see a few lines like the ones above.
Some more comments:
- The two parts of the string together are never going to exceed
N
. N
is a constant value.- I've already got the two strings, I don't need any date formatting.
Is it posible to do this using Python's string `format ìn a generic way? Something like:
N=80
first_part_of_the_string = "===>>> [FINISHED] Building sources: " + some_random_text
second_part_of_the_string = my_function_to_convert_time_to_hms(time)
print("{<}{:N>}".format(first_part_of_the_string, second_part_of_the_string))