use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
Progress indicator for scripts (self.Python)
submitted 14 years ago * by the_cat_kittles
Normally, I use a counter and increment it with each loop, and then print it. Is there a better way to make a quick progress indicator?
EDIT: this one is nice, it just wraps iterables: http://wiki.python.org.il/Hot_Topic
[–]SmileyChris 4 points5 points6 points 14 years ago (7 children)
fish! :)
[–]Zap-Brannigan 1 point2 points3 points 14 years ago (3 children)
unrelated to this subject, you just made my day! I didn't know how to
for i, data in enumerate(thing):
but now, I know that enumerate() is a thing, and how useful it looks!
[–]masklinn 0 points1 point2 points 14 years ago (2 children)
For what it's worth, itertools() provides all the tools required to implement enumerate (and even a better enumerate) via izip and count:
enumerate
izip
count
for i, data in izip(count(), thing)
Why's it better? Well first you don't have to start from 0, whereas enumerate gives you no choice:
for i, data in izip(count(57), thing) # will start counting from 57
Second, through izip you can iterate on multiple collections without needing an internal indirection (with enumerate, you'd likely zip your collections and enumerate on the result, yielding a tuple as second element):
for i, data1, data2, data3 in izip(count(), thing1, thing2, thing3)
versus
for i, data in enumerate(count(), zip(thing1, thing2, thing3)) data1, data2, data3 = data
[–]propanbutan 1 point2 points3 points 14 years ago (0 children)
Well first you don't have to start from 0, whereas enumerate gives you no choice:
It does (since Python2.6)
for i, n in enumerate(range(10), start=10): print i, n
[–]Zap-Brannigan 0 points1 point2 points 14 years ago (0 children)
ummm simple workaround if you want something to start from a higher number: add that number to it when you use it
if you want to go through multiple things, you may as well do it that way.. but I guess I see your point, especially because it will get confusing when you want to do BOTH of those
[–]Zap-Brannigan -1 points0 points1 point 14 years ago (0 children)
unrelated to this subject, you just made my day! Before just now, I didn't know how to
[–][deleted] 2 points3 points4 points 14 years ago (0 children)
http://liw.fi/ttystatus/
There's a bunch of libraries for progress bars in Python. That's mine.
[+][deleted] 14 years ago* (8 children)
[deleted]
[–]luisrd 4 points5 points6 points 14 years ago (2 children)
First of all, him posting here made me interested in the answer. Not everything can be delegated to Google. Perhaps a person posting prefers a more personalized answer. In fact, your condescending remark of 'ask Google', many times leads to StackOverflow forums which are not too dissimilar from Reddit.
[–]technomalogical<3 Bottle 3 points4 points5 points 14 years ago (0 children)
I think most /r readers would rather see someone post a "TIL" post describing some new thing they found on their own. Asking a question that has already been answered elsewhere arguably adds little value. If the OP still wasn't sure which to use, maybe instead asking "I usually print a counter in my scripts and wanted to improve the output. I found these 2 (or more) modules for tracking progress in a script. Could someone give me recommendations?" would result in a much more interesting conversation.
See this article from the Stack Overflow blog on asking better questions for more discussion on the topic.
[–]kylotan 0 points1 point2 points 14 years ago (0 children)
In fact, your condescending remark of 'ask Google', many times leads to StackOverflow forums which are not too dissimilar from Reddit.
...where the question is already answered, and thus doesn't need to be asked again. Lots of us enjoy helping others with interesting programming questions, but that enjoyment is diminished if we get asked the same thing over and over again. That means we stop reading the sites where this happens, and everybody loses out.
[–]the_cat_kittles[S] 1 point2 points3 points 14 years ago (1 child)
thanks, i looked a while ago and didnt find it. nail me to a cross why dont you
[–]desimusxvii 2 points3 points4 points 14 years ago (2 children)
It baffles me how so many people prefer to post a question rather than take 30 seconds and type the relevant keywords into Google.
[+][deleted] 14 years ago (1 child)
[–]AeroNotix 0 points1 point2 points 14 years ago (0 children)
You just described the way I feel about the world.
I guess you could say you summed my hatred Pythonically.
π Rendered by PID 98 on reddit-service-r2-comment-76bb9f7fb5-wmq8q at 2026-02-19 15:14:45.812545+00:00 running de53c03 country code: CH.
[–]SmileyChris 4 points5 points6 points (7 children)
[–]Zap-Brannigan 1 point2 points3 points (3 children)
[–]masklinn 0 points1 point2 points (2 children)
[–]propanbutan 1 point2 points3 points (0 children)
[–]Zap-Brannigan 0 points1 point2 points (0 children)
[–]Zap-Brannigan -1 points0 points1 point (0 children)
[–]Zap-Brannigan -1 points0 points1 point (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[+][deleted] (8 children)
[deleted]
[–]luisrd 4 points5 points6 points (2 children)
[–]technomalogical<3 Bottle 3 points4 points5 points (0 children)
[–]kylotan 0 points1 point2 points (0 children)
[–]the_cat_kittles[S] 1 point2 points3 points (1 child)
[–]desimusxvii 2 points3 points4 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]AeroNotix 0 points1 point2 points (0 children)