Formatting 3 integers (hours, mins, secs) to `00:00:00`? I have this at the moment, wondering if there's a cleaner way to do it or if this is already as compact as it gets. 

 h = "%s" % str(h) if h &gt;= 10 else "0%s" % str(h)
 m = "%s" % str(m) if m &gt;= 10 else "0%s" % str(m)
 s = "%s" % str(s) if s &gt;= 10 else "0%s" % str(s)
 print("{}:{}:{}".format(h, m, s))
The % formatting operator already supports 0-padding, just specify the width as 02. Also, you can pass a tuple to combine multiple numbers into the same string with a single format: "%02d:%02d:%02d" % (h, m, s).

In Python 3 the format string method is slightly preferred to the % operator, with Python 3.6 further allowing the format string to reference the variables directly. Using such formatted string literals or f-strings, the formatting would be expressed as: f"{h:02}:{m:02}:{s:02}".

As pointed out in the comments, if you're starting with datetime objects to begin with, you can use their own formatting functionality instead.