Is there any string formatting for using correct suffix with log messages, for example:
for n in itertools.count():
print 'printing for the {:nth} time'.format(n)
Expected output:
printing for the 0th time
printing for the 1st time
printing for the 2nd time
printing for the 3rd time
printing for the 4th time
printing for the 5th time
...
printing for the 23rd time
...
printing for the 42nd time
...
etc
I could roll my own fairly easily, but I was wondering if there was already a built-in solution. If not, I will accept as answer the most elegant solution!
Not extremely efficient, but definitely a one-liner ;)
What about simply:
Or if you prefer ugly hacks:
I felt a bit dirty while writing that one.