Skip to content

Instantly share code, notes, and snippets.

@RecNes
Last active June 20, 2018 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RecNes/a803a9d3705c3017e9a09d9948a01881 to your computer and use it in GitHub Desktop.
Save RecNes/a803a9d3705c3017e9a09d9948a01881 to your computer and use it in GitHub Desktop.
Display percentage of process to on one line of stdout in python
object_list_length = len(ObjectList)
for i, object in enumerate(ObjectList):
percentage = int(((i + 1) * 100 / object_list_length))
percent_str = ""
for k in range(0, int(percentage / 5)):
percent_str += ":"
sys.stdout.write("\r%s -- %s | %s %% %s " % (str(i + 1),
str(object_list_length),
str(percentage),
percent_str)
)
sys.stdout.flush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment