Published | Last Update
289 views, 0 RAMs, and 0 comments
Commentary is hard. Use your reading skills to read this code:
#!/usr/bin/env python # -*- coding: utf-8 -*- import time import sys from termcolor import colored def basic_progress_bar(current, end, num_chars=100): if ( (not isinstance(current, int) and not isinstance(current, float)) or (not isinstance(end, int) and not isinstance(end, float)) ): return colored("??? / ???", 'red') if current > end: current = end percent = ( float(current) / float(end) ) percent_complete = int((num_chars*percent) ) percent_incomplete = num_chars - percent_complete #pb = str(current).zfill( + " " pb = str( int(percent*100) ).rjust(3) + "% " pb += "=" *percent_complete if (percent < 1.00): pb += "~" * (1) else: pb += "=" * (1) pb += "-" * percent_incomplete pb += " " t = len(str(end)) pb += str(int(current)).rjust(t) + " out of " + str(int(end)).rjust(t) return pb # Demo usage while True: c = 0.000 sys.stdout.write(basic_progress_bar(c, 60) +"\r") ; sys.stdout.flush() while c < 60: c += random.uniform(0,1) sys.stdout.write(basic_progress_bar(c, 60) +"\r") ; sys.stdout.flush() time.sleep(0.01) print "" time.sleep(1)
Sir, I can do you a nice SEO.
Post a New Comment
Do you like having a good time?
Register an Account
Read Quality Articles
Read some quality articles. If you can manage to not get banned for like five minutes, you can even post your own articles.
Argue with People on the Internet
Use your account to explain why people are wrong on the Internet forum.
Vandalize the Wiki
Or don't. I'm not your dad.
Ask and/or Answer Questions
If someone asks a terrible question, post a LMGTFY link.
Make Some Money
Hire freelancers and/or advertise your goods and/or services. Hire people directly. We're not a middleman or your dad. Manage your own business transactions.
Answers— Read More
Find more related content below!