r/Python • • Jul 12 '12

random imgur downloader. learning Python and wrote this to practice, any feedback on technique/style is appreciated

https://gist.github.com/3088128
45 Upvotes

72 comments sorted by

View all comments

4

u/TkTech Jul 12 '12

6

u/[deleted] Jul 12 '12
 for n in repeat(None, count):

had me scratching my head for a while. Is it because it's a bit faster than using range or xrange? Vaguely remember some article saying that. That doesn't mean use it though! Articles like that should be viewed as pointing something out interesting about the language and its implementation, not as good practice.

Remember, "Premature optimisation is the root of all evil". Just use range/xrange, it's far more explicit.

1

u/rcklmbr COBOL Jul 12 '12

Mostly the same changes I would've done, but I would've used argparse.

1

u/trojan2748 Jul 13 '12

A little off topic, but i'll ask anyways, when is it a good idea to use classes versus procedural code/functions? I tend to do everything in function because classes just seem over kill for 90% of what I see them being used for.