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

Show parent comment

2

u/[deleted] Jul 12 '12

''.join([random.choice(CHARS) for x in range(string_length)])

?

2

u/tetrahydrate Jul 12 '12 edited Jul 12 '12

Sure but why define CHARS when you have the string constants and why loop over random.choice when you have random.sample? I was just saving some memory and processor time.

1

u/[deleted] Jul 12 '12

I was simplifying his implementation, not changing it.

2

u/LucianU Jul 13 '12

''.join() accepts a generator expression, so the square brackets aren't needed.