It doesn't.
You can indent two spaces to get monospaced, unwrapped text, and that’s all the code formatting you get.
the visual display of this progress indicator is different yes -
This method doesn't need any notion of terminal width because it just prints 'N / N' at the beginning of the current line where the cursor is when called.
fwiw, line_len=79 is the default on both windows and linux ime. You would only encounter overflow if you (1) shrunk the terminal from its default width and (2) printed a message that was longer than that shrunken width.
If you really needed to have a progress bar that accounted for a shrunken display, it could be accomplished trivially with Python 3.? and less-trivially with Py2.
I could see depending on this library if the application was client facing and needed to be automagically pretty.
Also, one thing to note is that tqdm only fetches the console width when init'ing a progress bar... if you shrink the terminal while a progress bar is still "in progress," you will encounter the same overflow issue.
https://i.imgur.com/fvEeaJA.png
My library function is:
import sys def writeToTerminal(txt, line_len=79): # line_len is the max num of characters that can fit onto a terminal line without overflowing to a newline
Example usage:from time import sleep L = list(range(10)) for c, i in enumerate(L, start=1): writeToTerminal("%i / %i" %(c, len(L))) sleep(1)